Localization & URLs for Default Language

Rafael Bugajewski <[email protected]> Fri, 6 Sep 2019 10:45:22 +0200
Newsgroups gmane.comp.java.tapestry.user
Message-ID <[email protected]>
Hello,

Tapestry supports putting the current locale into the URL path. I=E2=80=99=
m injecting PersistentLocale and switching between languages as advised =
in the documentation:

if (persistentLocale.get() =3D=3D 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=E2=80=99t want. Trying to set =
Locale.ROOT as the locale for the default language after switching from =
German doesn=E2=80=99t work, because "" (which Locale.ROOT effectively =
represents) isn=E2=80=99t configured in =
SymbolConstants.SUPPORTED_LOCALES.

The only thing I=E2=80=99ve 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]