Reputation: 1393
i used .properties files to manage the language in java code. but how to change the language manually, i mean when the user want to change the language. in other word what google and facebook did to manage this ?
Upvotes: 2
Views: 1624
Reputation: 10543
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
setLocale(request, Locale.ITALY); // This is inherited method.
return mapping.findForward(SUCCESS);
}
Call setLocale() method with arguments request and java.util.Locale. Make sure that you have respective ApplicationResource_it_IT.properties in your resource path in this case.
Upvotes: 0
Reputation: 23373
You might want to look at storing your UI texts in resource bundles, then offer your users a choice of locales that are known to the application and reload the UI for the user from the bundle loaded using the locale chosen.
Upvotes: 1