[MAGNOLIA-8733] Add Locale variant support to I18nContentSupport Created: 01/Feb/23 Updated: 23/Oct/23 |
|
| Status: | Open |
| Project: | Magnolia |
| Component/s: | i18n |
| Affects Version/s: | 6.2.28 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Richard Gange | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Template: |
|
||||||||||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||||||||||
| Epic Link: | Support | ||||||||||||||||||||||||
| Team: | |||||||||||||||||||||||||
| 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 |