ResourceBundle in Google App Engine Servlet does n

2019-07-24 08:56发布

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条回答
乱世女痞
2楼-- · 2019-07-24 09:38

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

查看更多
登录 后发表回答