Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-5125

Locale handling is broken with ISO 639-2 more than two letters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 4.4
    • None
    • Gentoo Linux, Java 1.7.0

    Description

      Apache Commons Lang support only two letter with wariants

      Apache org.apache.commons.lang.LocaleUtils
      line 99:

      if (len != 2 && len != 5 && len < 7) {
                  throw new IllegalArgumentException("Invalid locale format: " + str);
              }
      

      Patch ugly, but showing what is broken

      # This patch file was generated by NetBeans IDE
      # It uses platform neutral UTF-8 encoding and \n newlines.
      --- HEAD
      +++ Modified In Working Tree
      @@ -109,8 +109,15 @@
       
           @Override
           public void i18nIze(Dialog dialog) {
      +        final String configValue = dialog.getConfigValue("locale", null);
               // TODO: should this be set in the aggregation state?
      -        Locale locale = LocaleUtils.toLocale(dialog.getConfigValue("locale", null));
      +        Locale locale;
      +        try {
      +            locale = LocaleUtils.toLocale(configValue);            
      +        } catch (IllegalArgumentException iae) {
      +            //language ISO 639 alpha-2 or alpha-3 language code,
      +            locale = new Locale(configValue);
      +        }
               boolean isFallbackLanguage = i18nContentSupport.getFallbackLocale().equals(locale);
       
               if (isEnabled() && i18nContentSupport.isEnabled() && locale != null) {
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              m1k0 Michał Kudła
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD