Java JRE:如何将本地化资源添加到stantard JRE资源 [英] Java JRE: How to add localized resources to stantard JRE resources
问题描述
我需要JRE才能使用仅以英文提供的JRE资源的翻译版本。
I need the JRE to use translated versions of a JRE resource that is available only in English.
根据ResourceBundle.java文档,它很容易:添加本地化具有正确语言环境后缀的资源。例如,标准
As per the ResourceBundle.java doc, it's easy: add localized resources with the right locale suffix. For example, the standard
- XMLSchemaMessages.properties
将成为翻译版本:
- XMLSchemaMessages_FR.properties
等等。
编辑:此特定文件位于:
com \\\\\\\\\\\\\\\ xerces\internal\impl\msg\XMLSchemaMessages.properties
this particular file lives in : com\sun\org\apache\xerces\internal\impl\msg\XMLSchemaMessages.properties
我的问题是:如何让这些额外的资源对JRE可见?
My question is: how do I make those extra resources visible to the JRE ?
提前致谢,任何帮助。
- 欢呼
Thanks in advance, for any help. -- cheers
推荐答案
假设Xerces使用ResourceBundle来获取消息,你应该在
Assuming that Xerces uses ResourceBundle to get the messages, you should put a new file in
com\sun\org\apache\xerces\internal\impl\msg\XMLSchemaMessages<locale>.properties
其中locale是您需要的语言环境的正确标识符。
where locale is a correct identifier for the locale you need.
然后确定加载XMLSchemaMessages资源包的确切位置,并设置断点,以便单步执行JRE中的ResourceBundle加载过程(这里建议使用JDK) ,所以你有运行时的来源),你可以看到正在搜索的内容。
Then pinpoint the exact location where the XMLSchemaMessages resource bundle is loaded, and set a breakpoint so you single step through the ResourceBundle loading procedure in the JRE (a JDK is recommended here, so you have source for the runtime) and you can see what is being searched for.
注意:你正在处理特定于供应商的XML Parser,这意味着这将是特定于Oracle,甚至可能仅适用于某些Java版本。考虑引入自己的验证XML Parser并将其本地化?
Note: You are dealing with a vendor specific XML Parser here meaning this will be Oracle specific and may even only work on some Java versions. Considered bringing in your own validating XML Parser and localize it instead?
这篇关于Java JRE:如何将本地化资源添加到stantard JRE资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!