我正在使用
Java6作为我的Web应用程序我正在尝试下面的代码来改变我的应用程序的laguage
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); }
它工作正常,但当我试图改变印地语时,我没有看到任何印度语语言环境.
我们是否也可以从Java支持hindi Locale,以便我的应用程序可以用于印地语.
解决方法
Java 6肯定有hindi Locale支持,请参考
here
要将语言环境显式设置为印地语,印度会执行以下操作:
System.out.println(new Locale("hi","IN"));
打印;
hi_IN
这里要注意的是Locale
还提供构造函数来准确地获取受支持的Locale和变体的句柄.
因此,在您的代码中,您可能想要尝试:
Locales.setThreadLocal(Locales.getLocale(new Locale("hi","IN")));