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

Add Locale variant support to I18nContentSupport

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Medium
    • None
    • 6.2.28
    • i18n
    • None

    Description

      The class java.util.Locale provides three constructors:

      Locale(String language)
      Locale(String language, String country)
      Locale(String language, String country, String variant)
      

      Currently in AbstractI18nContentSupport we do not make use of the variant constructor option:

          protected static Locale determineLocalFromString(String localeStr) {
              if (StringUtils.isNotEmpty(localeStr)) {
                  String[] localeArr = StringUtils.split(localeStr, "_");
                  if (localeArr.length == 1) {
                      return new Locale(localeArr[0]);
                  } else if (localeArr.length == 2) {
                      return new Locale(localeArr[0], localeArr[1]);
                  }
              }
              return null;
          }
      

      Nor do we use it on LocaleDefinition

          /**
           * Creates the locale for this definition if not yet set.
           */
          public Locale getLocale() {
              if (locale == null && getLanguage() != null) {
                  locale = new Locale(getLanguage(), StringUtils.defaultString(getCountry()));
              }
              return locale;
          }
      

      Consider the case of the Valencian language which is a variant of Catalan from country of Spain.

      Looking at the subtag registry:

      %%
      Type: variant
      Subtag: valencia
      Description: Valencian
      Added: 2007-03-06
      Prefix: ca
      Comments: Variety spoken in the "Comunidad Valenciana" region of Spain,
        where it is co-official with Spanish.
      

      I should be able to configure something like:

      'ca-valencia':
        'country': ''
        'enabled': true
        'language': 'ca'
        'variant': 'valencia'
      

      Which then should show up in the language switcher as: Catalan-Valencian

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                rgange Richard Gange
                DeveloperX
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:

                  Checklists

                    Task DoD