|
Our goal is to give to the user the possibility to change the language used to browse the Web application. In this example only the current page is localized using the language chosen by the user.
In order to accomplish this example, it is necessary to go through the following steps:
- Add a Page to the Site View: select the "Page" icon from the palette, and place it on the Site View. Change the page name (setting "Choose Language") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
- Localize the page: In order to make the page use the language chosen by the user, enable the flag "Localized" in the Properties View of the page.
- Add an Index Unit to the page: select the Index Unit icon from the palette and place it inside the page. Change the "Name" property in "Languages".
- Set the Entity on which the Index Unit is based: click on the "Edit" button next to the "Entity" property in the Properties View. Then choose the "Language" Entity from the opened dialog pane.
- Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the "language", "languageISOCode" and "countryISOCode" attributes from the opened dialog.
- Define the sort criteria of the Index Unit: click on the "Edit" button next to the "Sort Attributes" property, then choose the "language" attribute and the "ascending" sort criteria.
- Add a Reset Unit to the page: select the Reset Unit icon from the palette and place it outside the page. Change the "Name" property in "Reset Language".
- Set the Context Parameter on which the Reset Unit is based: click on the "Edit" button next to the "Context Parameter" property in the Properties View. Then choose the "LanguageISOCtxParam and CountryISOCtxParam" Context Parameter from the opened dialog pane.
- Draw a normal link between the "Languages" Index Unit and the "Reset Language" Reset Unit: select the Link button from the palette and click on the "Languages" Index Unit (the Source of the Link) and then on the "Reset Language" Reset Unit (the Target of the Link). Set the Name property of the newly created Link to "Select" and the Type property to "normal".
- Define the parameters coupling: open the Parameters Coupling window of the newly created link in order to define the coupling between the output parameters of the source Unit and the input parameters of the target Unit.In the Parameters Coupling dialog, couple the "languageISOCode" Attribute of the Index Unit with the "LanguageISOCtxParam" Context Parameter of the Reset Unit and the "countryISOCode" Attribute of the Index Unit with the "CountryISOCtxParam" Context Parameter of the Reset Unit.
- Draw an OK link between the "Reset Language" Reset Unit and the "Choose Language" page: select the Link button from the palette and click on the "Reset Language" Reset Unit (the Source of the OK Link) and then on the "Choose Language" page (the Target of the OK Link). Set the Name property of the newly created OK Link to "Language Set".
- Add supported language: right click in the Work Area and select the Localize item. In the opened dialog right click on "Locales" and add as many locales as you want (e.g. italian and english). Set the messages for all the labels of the page and confirm with the OK button.
- Generate the Web application: click on "Generate Full Web Project" on the WebRatio Menu Bar. Once the generation process has completed, it is possible to start the application server and test the Web application.
|
The Web Model of the example
|
The Properties View of the Index Unit
|
The Properties View of the Reset Unit
|
The "Select" Link Parameters Coupling window
|
|