You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Geoff Callender (JIRA)" <de...@tapestry.apache.org> on 2008/03/21 15:05:26 UTC
[jira] Commented: (TAPESTRY-1997) PersistentLocale is lower-casing
locales
[ https://issues.apache.org/jira/browse/TAPESTRY-1997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581081#action_12581081 ]
Geoff Callender commented on TAPESTRY-1997:
-------------------------------------------
It appears there is no problem as long as you use the following guidelines:
1. Use lower-case locale names for supported-locales, eg. in AppModule:
public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration) {
configuration.add("tapestry.supported-locales", "en_gb,en_us,fr");
}
2. In the page class, get the current locale like this:
@Inject
private Locale _locale;
instead of like this:
@Inject
private PersistentLocale _persistentLocaleService;
Locale locale = _persistentLocaleService.get();
When guideline 1 is ignored, then these 4 statements all seem to select the first English supported locale:
_persistentLocaleService.set(new Locale("en_GB");
_persistentLocaleService.set(new Locale("en_gb");
_persistentLocaleService.set(new Locale("en_US");
_persistentLocaleService.set(new Locale("en_us");
When it IS followed, then all is well, although this makes me uneasy because I'm not sure that "en_gb" and "en_us" are actually valid locales.
Guideline 2 returns a _locale that is correctly mixed case, eg. "en_GB" or "en_US", whereas _persistentLocaleService.get() does not - it returns a lower-cased locale, eg. "en_gb" or "en_us" which is useless for formatting things correctly (see original comments in this issue).
These guidelines are OK as a work-around, but my vote is that the handling of supported-locales should be changed. Requiring lower-case is confusing and, I suspect, not even correct.
> PersistentLocale is lower-casing locales
> ----------------------------------------
>
> Key: TAPESTRY-1997
> URL: https://issues.apache.org/jira/browse/TAPESTRY-1997
> Project: Tapestry
> Issue Type: Bug
> Components: tapestry-core
> Affects Versions: 5.0.6
> Reporter: Geoff Callender
>
> An issue affecting localization: PersistentLocale is converting locales from mixed case to all lower case, which is useless for formatting. For example, if page 1 sets the locale like this:
> @Inject
> private PersistentLocale _persistentLocaleService;
> Locale locale = Locale.UK;
> _persistentLocaleService.set(locale);
> System.out.println("locale is " + locale + " - " + locale.getDisplayName());
>
> then this is what prints:
> locale is en_GB - English (United Kingdom)
> But when I'm in page 2 I get the locale and find it has mutated...
> Locale locale = _persistentLocaleService.get();
> System.out.println("locale is " + locale + " - " + locale.getDisplayName());
> ...this is what prints:
> locale is en_gb - en_gb
> This mutated locale in page 2 is useless for formatting. Code like the following produces default-styling instead of the styling for en_GB:
> _myDateFormat = DateFormat.getDateInstance(DateFormat.LONG, locale);
> System.out.println(_myDateFormat.format(new Date()));
> It seems this has also adversely affected how supported-locales are declared (maybe in previous releases only). See http://thread.gmane.org/gmane.comp.java.tapestry.user/56526/focus=56527
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org