Reputation: 12592
I have my project which has two language (en,fi). But when I try to access a file which has a url without locale it points me to the en page. But onActiavat
I forced persistentLocale
to be fi if user has not selected any. This will make all my links in the page to point into fi pages, but not the current page. Any suggestions on how to make this happen. I don’t want browser language to be default or anything else. System will force the language on user login by reading user profile. But before login if user has not selected any language preference (in case of persistentLocale.get() == null
) I want to display fi pages.
Upvotes: 1
Views: 655
Reputation: 27994
Why not put your finnish translations in page.properties
and put your english translations in page_en.properties
.
Upvotes: 1
Reputation: 139
Drop this in your module. This code decorates the ThreadLocale and it sets the threadLocale to your prefered locale if it's not set already (URLs without locale).
@Decorate(serviceInterface = ThreadLocale.class)
public ThreadLocale decorateThreadLocale(final ThreadLocale threadLocale,
final PersistentLocale persistentLocale)
{
return new ThreadLocale()
{
@Override
public void setLocale(Locale locale)
{
threadLocale.setLocale(locale);
}
@Override
public Locale getLocale()
{
if (!persistentLocale.isSet())
{
setLocale(new Locale("fi"));
}
return threadLocale.getLocale();
}
};
}
Upvotes: 1