Skip to content

Localiztion

Paul Schwartz edited this page Jun 1, 2015 · 3 revisions

How do you add localization to values pulled from the database The problem being solved is that values from the database are often displayed to the user as a list and even though the language on the page changes, the language for the list doesn't. There are five steps to add the localization.

Add a new column to the table for a MessageResource key Override getDefaultLocalizedName() in the java object mapped to the table Add the mapping to the hibernate mapping file Add the localized text to the MessageResource files. Methods should use getLocalizedName() Look at the table panel as an example.

Table column The recommended method is to use liquidbase files. But if you must: ALTER TABLE clinlims.panel ADD COLUMN display_key varchar(60); Override getDefaultLocalizationName() The actual code for handling the localization is in BaseObject.java. However if the key in the table is null or not found in MessageResources then something has to be displayed to the user. Each derived class supporting database localization should override this method. If not then unknown will be displayed. Hibernate mapping files The following should be added to the hibernate mapping file Add localized text to the resource file Just do it Code should call getLocalizedName() Obviously only code that knows that it is calling objects which support localization.

Clone this wiki locally