Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-14994

Taxonomy on compound level doesn't recognize document locale

    XMLWordPrintable

Details

    • Flagged
    • Client Service Team

    Description

      When a taxonomy field is configured in a compound, the tree labels in the taxonomy picker are in the user locale, not in document locale, like is the case when configured on document level.

      See

      Analysis: the method org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin#getPreferredLocale looks at document level only.

          /**
           * Returns the translation locale of the document if exists.
           * Otherwise, returns the user's UI locale as a fallback.
           */
          protected Locale getPreferredLocale() {
              final Node node = getModel().getObject();
              try {
                  if (node.isNodeType(HippoTranslationNodeType.NT_TRANSLATED)
                          && node.hasProperty(HippoTranslationNodeType.LOCALE)) {
                      return TaxonomyUtil.toLocale(node.getProperty(HippoTranslationNodeType.LOCALE).getString());
                  }
              } catch (final RepositoryException e) {
                  log.error("Failed to detect " + HippoTranslationNodeType.LOCALE + " to choose the preferred locale", e);
              }
      
              return getLocale();
          }

      Set up:
      Create a compound, add hippotaxonomy:classifiable in its nodetype namespace

      /hippo:namespaces/myproject/mycompound/hipposysedit:nodetype/hipposysedit:nodetype
        hipposysedit:supertype: ['hippo:compound', 'hippostd:relaxed', 'hippotaxonomy:classifiable']
      

      And add an editor field:

      /hippo:namespaces/myproject/mycompound/editor:templates/_default_/classifiable
        jcr:primaryType: frontend:plugin
        mixin: hippotaxonomy:classifiable
        plugin.class: org.hippoecm.frontend.editor.plugins.mixin.MixinLoaderPlugin
        wicket.id: ${cluster.id}.field
        /cluster.options:
          jcr:primaryType: frontend:pluginconfig
          taxonomy.name: mytree
      

      Then create a non-English content tree with the same non-English taxonomy item labels.

      Attachments

        1. CMS-14994.png
          CMS-14994.png
          148 kB
        2. CMS-14994-fixed.png
          CMS-14994-fixed.png
          132 kB
        3. myproject15.2.0-tax.zip
          319 kB

        Activity

          People

            jhoffman Jeroen Hoffman
            jhoffman Jeroen Hoffman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: