开发者

How to overwrite a resource bundle property

开发者 https://www.devze.com 2023-03-29 22:17 出处:网络
Is it possible开发者_C百科 to overwrite a String property from a resource bundle that is located in a jar ?

Is it possible开发者_C百科 to overwrite a String property from a resource bundle that is located in a jar ?

I've been given a bunch of jars to develop an multi language application but the jars only include a single resource file, so when I set the Locale to, say, German, only the resouece file I have provided a german version for are translated of course ; the user facing strings coming from the jars are still in english.

so I was thinking I would need to duplicate and then overwrite (not great, but that's all I can think of) the property in one of the resource file in my code, so it can be translated in the other resource files that I also provide.

Is that even possible ?

Does it perhaps depends on the sequence in which the various resource bundles are loaded ?

Many thanks for your help


You will have to provide additional resource file per localization (de,it,fr...) requirement. Do not overwrite anything in the JAR. Go through the JARs and figure out each resource bundle file name and provide (in classpath) a localized version of it with your application.


As far as I understand your question you have application with English version of resource bundle and you want to translate it to German. To do this you have to take the English resource bundle, create its copy, rename it to something like TheBundle_de.properties, then translate all texts to German and package this file with your application to make it accessible as resource. Now use regular java localization mechanism and everything will work fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消