Good idea to wrap that in a library. Thanks for doing the work for me!
Particularly the documentation process.
Some little suggestions:
- Put the library in a package, so we
import com.0p0media.i18n.I18n; (for example) instead: it is cleaner and might reduce risks of clashes. (or just
import com.0p0media.I18n; if you prefer and don't plan to have lot of libraries...).
- Remind in your Working with the ResourceBundle page that the properties files must be encoded in UTF-8. Perhaps change the name of this page, since ResourceBundle class is actually hidden...
- Note you can even put spaces at the start of the continuation lines (multiline strings), they are gobbled up.
- Maybe add an option to the I18n class to display the key instead of Xxx, like I did, as you often have incomplete translations (lagging behind current version of software) and giving the key might hint of the original meaning.
- You mention a
folder called “Localization.properties”, I suppose it is a file, no?
- The fact the translations files are not packaged when exporting the application is only an half problem: most applications just give these files separately, allowing easier update (or editing) and selecting only the files useful to a user (no need to get dozens of languages when you really need a couple of them).
- Actually, in my sketch, the localization files in the data folder are packaged in the jar, so I wonder what problem you have. I will investigate. It would be useful at least for applets.
- It might be interesting, for flexibility, to expose a way to choose the locale (can be done with Locale.setDefault, though).