Java JRE: How to add localized resources to stantard JRE resources

前端 未结 2 825
感动是毒
感动是毒 2021-01-14 12:46

I need the JRE to use translated versions of a JRE resource that is available only in English.

As per the ResourceBundle.java doc, it\'s easy: add localized resource

2条回答
  •  时光说笑
    2021-01-14 12:57

    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.properties 
    

    where locale is a correct identifier for the locale you need.

    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.

    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?

提交回复
热议问题