Client resources
When configuring client items in Weave it's possible to set the text displayed to the user for various items directly, this is generally done by setting a 'label', 'text' or 'tooltip' type of properties for the items.
Previously when these values were set they would completely replace the value displayed for every user, however a recent update in Weave provides a way to set these values indirectly and have a different value provided to the user based on their location.
The actual values to be displayed to the users are set in a separate client resources configuration item, where you outline the text to be displayed to the user and give each piece of text a unique id, then reference that id where previously you'd use the text directly.
Referencing the text item is performed by prefixing the texts id with % where you'd usually put the text, for example
<view id="com.cohga.html.client.main.searchView"> <label>Search</label> <location>west</location> </view>
would be become
<view id="com.cohga.html.client.main.searchView"> <label>%search.label</label> <location>west</location> </view>
To actually define the text to be used you need to create a separate client resources
item
<client:resources> <resource id="search.label">Search</resource> </client:resources>
You can create as many resources configuration items as you like, this allows you to either keep one single large resources section or break them up and locate them close to the items that they're used in.
Keeping them in a separate file and including them into your configuration is also a useful way to reduce clutter.
The above example is intended to show the syntax required to configure text for localisation, and in itself hasn't really provided us with any advantage, since all we've done here is to replace the default text displayed for every client and that would've been easier just to replace the text directly.
However, the real point here is to allow the text to be changed for each user based on their preferred language, and the way we do that it to create another client resources item that contains the alternate text and specify what locale the user should ask for for that text to be used. To do this we duplicate the existing resources item and set a lang
property for the resources, for example:
<client:resources lang="sv"> <resource id="search.label">Hitta</resource> </client:resources> <client:resources lang="ru"> <resource id="search.label">находить</resource> </client:resources>
Here we've set alternate values for the search label for Swedish and Russin users, with no change required to the configuration for the search panel and nothing required from the user.