Hello,
Tapestry supports putting the current locale into the URL path. I’m injecting
PersistentLocale and switching between languages as advised in the
documentation:
if (persistentLocale.get() == null) {
persistentLocale.set(new Locale("de"));
} else if ("en".equalsIgnoreCase(persistentLocale.get().getLanguage())) {
persistentLocale.set(new Locale("de"));
} else {
persistentLocale.set(new Locale("en"));
}
The problem is that the default language should not have a prefixed URL path.
When the user goes to https://example.com/ the default language is rendered and
it is the desired behavior. When I switch the URL becomes
https://example.com/de/ which is also OK. But now when I try to switch back to
English (to the default language), the URL becomes https://example.com/en/
which I don’t want. Trying to set Locale.ROOT as the locale for the default
language after switching from German doesn’t work, because "" (which
Locale.ROOT effectively represents) isn’t configured in
SymbolConstants.SUPPORTED_LOCALES.
The only thing I’ve seen are some older threads where PersistentLocale was
copied, pasted & adjusted to allow null parameters. Is this workaround the only
way to go or is there an official, Tapestry way to not have the locale in the
URL path for the default language?
Best,
Rafael
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]