ResourceBundle in Google App Engine Servlet does not work as expected

£可爱£侵袭症+ 提交于 2019-12-10 23:49:21

问题


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


回答1:


Make sure your properties files are being copied into WEB-INF/classes. You can check this out using a command shell.



来源:https://stackoverflow.com/questions/10736571/resourcebundle-in-google-app-engine-servlet-does-not-work-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!