15 Replies Latest reply on Jul 9, 2014 1:06 PM by whoiskevin

    Override core i18n.properties in a plugin?

    mrowbory Advanced

      Should I be able to override core i18n.properties in a plugin?

       

      I've made a few changes to the 'get started' text which I took from the Jive source and I've popped it into a plugin, but it's not getting picked up.

       

      Any ideas?

        • Re: Override core i18n.properties in a plugin?
          mrowbory Advanced

          Ryan Rutan

           

          I know plugins are your forte, can you point me in the right direction here.

           

          I'm trying to override a set of i18n translations from the core, I put them in the custom_i18n file in a plugin, but they don't appear to get picked up.

           

          Many thanks,

           

          Martin

            • Re: Override core i18n.properties in a plugin?
              Ryan Rutan Guru

              Never tried this myself; however, one thing I noted is that all my plugin i18n files are in a plugin_i18n.properties file .  Honestly, I'm not sure if that’s just a convention or a requirement, but that might help.  Do you know if your translation tokens are available in memory (i.e. Try to use one that is not an override and see if it resolves)?

                • RE: Override core i18n.properties in a plugin?
                  mrowbory Advanced

                  Ok thanks Ryan I‘ll try that out.

                   

                  Do you know what file location in the plugin the properties file should sit?  I‘ve seen a couple of options

                    • Re: Override core i18n.properties in a plugin?
                      Ryan Rutan Guru

                      I've always placed it in /src/main/resources in my plugin MAVEN project, which put it into /classes/plugin_i18n.properties.  Never had any problems with that =)

                        • Re: Override core i18n.properties in a plugin?
                          mrowbory Advanced

                          Hi Ryan,

                           

                          I added a custom string to my properties file which does get picked up.  However the core string I'm overriding remains the default and not my new one.

                           

                          Could you suggest anyway I might be able to override these strings?  There are more than I'd like to try and do manually using phrase substitutions, although I suppose I could put them directly into theme.xml?

                            • Re: Override core i18n.properties in a plugin?
                              Ryan Rutan Guru

                              I'd code them into the theme.xml.  At least that's the only other way that comes to mind.

                                • Re: Override core i18n.properties in a plugin?
                                  mueller-ziebur Advanced

                                  Hey guys,

                                   

                                  overriding jive i18n-keys (properties) via plugin has always been supported since clearspace (some of the elderly might remember ) and was considered best practice.

                                   

                                  Example:

                                  jive ootb-key:  global.task = Task

                                   

                                  /some-plugin/src/main/resources/plugin_i18n_en.properties

                                  global.task = ToDo

                                   

                                  This method of customising jive's ootb wording is not working anymore since jive6.

                                   

                                  While migrating our UI Editor we have discovered that this problem can easily be fixed with the following code change:

                                   

                                  --> com.jivesoftware.community.i18n.ResourceBundleLocator.Impl

                                  // SMZ: FIX

                                  // make sure the key of the last bundle in the list will be returned so  plugin_i18n-key overrides will work again

                                  // old method always returns the first key found (which is located in the jive_i18n-bundle

                                  private ResourceBundle searchResourceBundles(Locale locale, String key) {

                                      ResourceBundle result  = null;

                                      for (BundleAddress bundleAddress : allBundleAddresses) {

                                          ResourceBundle bundle = getBundleIfKeyExists(bundleAddress, locale, key);

                                          if (bundle != null) {

                                              result =  bundle;

                                          }

                                      }

                                      // Every one of these is a runtime drag on the system.

                                      LOG.debug("Unable to find text for key '" + key + "' in ResourceBundles for locale '" + locale + "'");

                                      return result;

                                  }

                                   

                                  You can overlay this class in your WAR.

                                   

                                  Ryan Rutan could you please reach out to the development team and check if this fix can be applied to the product in one of the next updates?

                                   

                                  There are a lots of customers out there that will soon migrate to jive6 and will discover that the translation overrides they have put into their plugins will not work anymore.

                                   

                                  Thanks Stephan

                      • Re: Override core i18n.properties in a plugin?
                        Likrant Advanced

                        Simple code can help you to transfer your properties into theme's rules )

                        public void initPlugin() {

                                ThemeManager themeManager=JiveApplication.getContext().getThemeManager();

                                PluginManager pluginManager=JiveApplication.getContext().getPluginManager();


                                Theme theme = themeManager.getTheme("theme_name");

                         

                                Locale locale = new Locale("en");

                                ResourceBundle resourceBundle = pluginManager.getPluginResourceBundle(this, locale);

                                List<ResourceBundleRule> resourceBundleRules = theme.getResourceBundleRules(locale);

                        //        if(resourceBundleRules==null)

                                    resourceBundleRules=new ArrayList<ResourceBundleRule>();

                         

                                ResourceBundle systemBundle=ResourceBundle.getBundle("jive_i18n");

                         

                                for (String key : resourceBundle.keySet()) {

                                    if(systemBundle.getObject(key).equals(resourceBundle.getObject(key)))continue;

                         

                                    ResourceBundleRule rule = new ResourceBundleRule();

                                    rule.setOperator(ResourceBundleRule.SearchOperator.EQUALS);

                                    rule.setSearchTarget(ResourceBundleRule.SearchTarget.KEY);

                                    rule.setPattern(key);

                                    rule.setReplaceValue(resourceBundle.getObject(key).toString());

                                    rule.setExcludeRules(new ArrayList<ResourceBundleRule.ExcludeRule>());

                                    resourceBundleRules.add(rule);

                                }

                                theme.setResourceBundleRules(locale, resourceBundleRules);

                                theme.loadResourceBundleRulesOverrides();

                                themeManager.updateTheme(theme);

                            }

                        • Re: Override core i18n.properties in a plugin?
                          mueller-ziebur Advanced

                          Hi all,

                           

                          just to let you know - this problem has now officially been promototed to status bug : JIVE-27815


                          Stephan

                          • Re: Override core i18n.properties in a plugin?
                            whoiskevin Expert

                            Just to update on this post.  As of 7.0.1.1 this is still not working.  Apparently it was either not fixed in 6 or it is a regression in 7.  Overrides in the plugin do not take affect.