I am using Java6 for my web application i am trying below code to change the laguage of my application
public static void doChangeLanguage(String argLang) {
SessionValidationInitiator.setLanguage(argLang);
LOGGER.debug("Changing Language to ... " + argLang);
if(argLang.equalsIgnoreCase("fr_ca")){
Locales.setThreadLocal(Locales.getLocale(Locale.FRENCH));
Executions.getCurrent().getSession().setAttribute(Attributes.PREFERRED_LOCALE, Locale.FRENCH);
Labels.reset();
}else{
Locales.setThreadLocal(Locales.getLocale(Locale.US));
Executions.getCurrent().getSession().setAttribute(Attributes.PREFERRED_LOCALE, Locale.US);
Labels.reset();
}
Executions.sendRedirect(null);
}
Its working fine but when i am trying to change the Hindi i saw no any locale for indian language.
Can we support Hindi Locale as well from Java so that my application work for Hindi Language.
Java 6 definitely has Hindi Locale support, refer to here.
To explicitly set the locale to Hindi, India do something like this:
System.out.println(new Locale("hi", "IN"));
Prints;
hi_IN
The thing to note here is Locale
does also offer constructors to accurately get a handle on the supported Locale(s) and variants.
Hence, in your code you might probably want to try out:
Locales.setThreadLocal(Locales.getLocale(new Locale("hi", "IN")));
In Java 6 you need this: Locale lc = new Locale("hi", "IN");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With