问题描述
有人能帮助我理解为什么使用 ResourceBundle
的国际化在Google App Engine Servlet中不能像在命令行Java应用程序中一样工作吗?
以下片段:
ResourceBundle resource_en_US,resource_de_DE,resource_ja_JP;
$ b code $ resource_en_US = ResourceBundle.getBundle(bundleBasename,Locale.US);
resource_de_DE = ResourceBundle.getBundle(bundleBasename,new Locale(de_DE));
resource_ja_JP = ResourceBundle.getBundle(bundleBasename,new Locale ja_JP));
logger.info(resource_en_US:+ resource_en_US.getLocale());
logger.info(resource_de_DE:+ resource_de_DE.getLocale());
logger.info(resource_ja_JP:+ resource_ja_JP.getLocale());
仅记录 en_US
在GAE中。
resource_en_US:en_US
resource_de_DE:en_US
resource_ja_JP:en_US
但是在命令行Java程序中记录适当的Locale。
r esource_zh_CN:zh_CN
resource_de_DE:de_DE
resource_ja_JP:ja_JP
属性文件被复制到WEB-INF / classes中。您可以使用命令外壳检查出来。
Can someone help me to understand why internationalization using ResourceBundle
does not work in Google App Engine Servlet the same way it works in a command line Java application?
The following snippet:
ResourceBundle resource_en_US, resource_de_DE, resource_ja_JP;
resource_en_US = ResourceBundle.getBundle(bundleBasename, Locale.US);
resource_de_DE = ResourceBundle.getBundle(bundleBasename, new Locale("de_DE"));
resource_ja_JP = ResourceBundle.getBundle(bundleBasename, new Locale("ja_JP"));
logger.info("resource_en_US:" + resource_en_US.getLocale());
logger.info("resource_de_DE:" + resource_de_DE.getLocale());
logger.info("resource_ja_JP:" + resource_ja_JP.getLocale());
Logs only en_US
in GAE.
resource_en_US:en_US
resource_de_DE:en_US
resource_ja_JP:en_US
But logs the appropriate Locales in command line Java program.
resource_en_US:en_US
resource_de_DE:de_DE
resource_ja_JP:ja_JP
Make sure your properties files are being copied into WEB-INF/classes. You can check this out using a command shell.
这篇关于Google App Engine Servlet中的ResourceBundle无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!