1

I have a resource bundle which consist of a few files, lets say:

  • address_en_us.properties
  • address_nl_nl.properties
  • address_fr_ca.properties

How do I obtain and merge two of the properties file with en_us being the 'default' property file?

Some background:

When I use one of the localized property, say, fr_ca, for each keys that are not localized in fr_ca, I want to use the default value specified in en_us

2 Answers 2

4

Just rename your "address_en_us.properties" to "address.properties" and this file is always used as 'default' property file.

0

One way I have seen work is to have the default values set in code, where it is hard-coded in java class. That way any property not set in properties file but used in code will always get the default value.

And from an architecture perspective this is also a really good idea, shipping products with default properties values in code, overridden by the values in properties file. And if you make it so that the product (Android app in my perspective) makes a server call at start-up to check and overwrite the values of properties files then you can add a lot of flexibility to the product.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.