...
The initial setup wizard will be run either when web-app starts after first deploy or when application data directory has changed. In turn, update wizard will be runned only if there are some new changes within liquibase file which are need to be applyed to database.
...
- Appropriate page should be shown for user at first step of the setup wizard;
- That page should contain selection list with all possible languages, checkbox for indicate that the selected language should be persisted after wizard’s finish and navigation element (next arrow) for continue;
- Selection list should be dynamically filled with languages basing on existing web app's message resource files;
- The user should be able to move back and forth through the each wizard's pages by using appropriate navigation elements (arrows are preferred in case when the text displayed is in a language they don't understand so well or if they selected a wrong language by mistake);
- When user is moving through the initial setup wizard's pages, language should not be changed until user will return to 1st page and change it;
- Selected by user language should be saved into cookie (or as http session's attribute) during wizard’s work and (if user have marked checkbox), it should be persisted into DB as admin’s property;
- When user is running the database update wizard, all pages should be displayed in previously persisted language or in English by default.
...
The first and the most important class in project structure is LocalizationTool. This class is intended for accessing ResourceBundles and formatting messages therein. For such porposes we also could use pure velocity's ResourceTool class, but it's not possible, because messages properties files are located outside web application classpath. In fact, this class extends velocity's ResourceTooland uses CustomResourceLoader for accessing messages from resource bundles, which are located outside the classpath. It overrides only two methods from super-class. First of these methods is get(Object, String, Object):Object is intended for obtaining message translation by specified key. Next method, is insert(Object):Key is used to support place holders for compound messages.
...
There are also two aspects of functionality, which should be described obligatory.They are related to stroing/retrieving user's locale properties within database. Considering with section Design components behaviour, for persisting locale as admin user's global property and as system default locale property, first it's need to create JDBC connection within database:
...
Even if currentLocale will be null, after this operation we will use OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE_DEFAULT_VALUE as locale parameter. And finally, we should take care about closing the connection to database by calling connection.close().
...