简体   繁体   English

使用ResourceBundle将属性文件从一种语言翻译成另一种语言

[英]Translate the Properties File from one language to another using ResourceBundle

I have message.properties file. 我有message.properties文件。 by default it will load as English when I use Locale and Resource Bundle in Java file. 默认情况下,当我在Java文件中使用“语言环境和资源包”时,它将以英语加载。 Now, I need to specify the Country Code or Type in Locale, Then the message.properties file key values should be load as the specified Country in Locale. 现在,我需要在区域设置中指定“国家代码”或“类型”,然后应该将message.properties文件键值加载为区域设置中的指定国家/地区。 How can I do this.? 我怎样才能做到这一点。?

Oracle has some example code of this here . Oracle 在这里有一些示例代码。

Basically you create bundles with the correct name for the language of the Locale and then load it with: 基本上,您使用正确的语言Locale名称创建捆绑,然后使用以下方式加载:

ResourceBundle.getBundle("LabelsBundle", currentLocale);

More information about internationalization .. 有关国际化的更多信息..

Also, before asking a question try googling for yourself.... 另外,在提出问题之前,请尝试自己搜索一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM