Moroianu Alexandru
Moroianu Alexandru

Reputation: 167

Modify Wicket's XML Resource Bundle with Java internationalization (i18n)

In the resource XML there are all these values associated with keys.I want to modify a value associated with a key directly from Java.

For instance,I have <entry key="greetingMessage">Welcome to my app</entry> and this is displayed in the view,but also the message can be modified from the view and I want to be automatically updated in the XML.

I have managed to do this by parsing and changing the XML with javax.xml and org.w3c but I feel I am missing something.Does Java internationalization or Wicket framework have a method to achieve this?

Upvotes: 0

Views: 253

Answers (1)

Roman Puchkovskiy
Roman Puchkovskiy

Reputation: 11865

Wicket only has facilities to read i18n resources (for example, XmlFilePropertiesLoader). Properties.storeToXML() is not used in Wicket 6 code, while Properties.loadFromXML() is used to read those XML properties files.

To store those translations back to XML files you need to be cautious. At least, synchronization has to be implemented to make sure that simultaneous edits are not lost.

I'd not recommend to store the edits in XML (especially in the original XML files). It seems better to have two levels of properties:

  1. First, immutable, level, is based on the original (and immutable) XML files.
  2. Second level consisting of 'edits' acts like a patch over the first level. It may be stored in a database which is much more convenient for storing a constantly updating data (like such edits).

Upvotes: 1

Related Questions