-
Improvement
-
Resolution: Unresolved
-
Medium
-
None
-
6.2.28
-
None
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
- duplicates
-
MAGNOLIA-8667 Allow variants of locales in i18n configuration
- Closed
- relates to
-
MAGNOLIA-8065 DefaultI18nContentSupport wrongly forwards to fallback locale as opposed to default locale on sub pages
- Closed
-
MAGNOLIA-8709 Allow use of IETF Language Tags
- In Progress