![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |
Each form has a base properties file that is generated automatically when the form is created, and is regenerated each time the form is saved. This file appears in Presentation Resources special folder in the Project Explorer. The base properties file contains the strings that appear as labels and messages in the form’s property sheets.Figure 123 Base Properties File
Do not edit the strings in the base properties file itself. Any changes you make to this file will be lost as soon as the project is built (which is to say, as soon as you save the form, with the default setting, where auto-build is enabled). To change the labels and messages for the base version of the form, use the form’s property sheets instead. The changes you make in the property sheets will appear in the base properties file when the form is saved.The renamed locale-specific versions of the properties file will not be automatically regenerated, and thus your locale-specific strings will not be lost when the form is saved.
1. Select the <form>.properties file from the Presentation Resources special folder in the Project Explorer. Make a copy of this file for each locale.
2.
3. For every new properties file created in the Presentation Resources folder, the builder automatically creates a matching <file>.properties.json file at the same location.
5. Click Project > Clean to clean and rebuild the project. This updates the <form>.locales.json file with the details of the language in which the form has been localized. For example, if you create DemoForm_fr.properties file, then the Demoform.locales.json will contain ["fr"]. This file is updated when the you rebuild the project after creating a new locale-specific version of the properties file.
6. Run the JDK command-line tool native2ascii, using the locale-specific properties file as input, to ensure that the file contains only ISO_8859-1-encoded characters:The native2ascii command-line tool is available in the directory %JDK_HOME%\bin.
You can find the directory that contains all the properties files by using the context menu of one of the form’s files in the Project Explorer (for instance, the base properties file) and clicking Properties to open the properties dialog. The path to the selected form resource is shown as Location:The form name, language code, and optional country code are separated by underscores. Table 18 shows examples of locale-specific properties files for a form named DemoForm.)
As shown in Table 18, if your form is called DemoForm, the automatically generated base properties file will be called DemoForm.properties. This is the file that will contain the strings typed on the form’s property sheets.To create a French version of this form, copy the DemoForm.properties file and rename the copy DemoForm_fr.properties. This is a language specific variant of the properties file which contains the translation for the French language.You can also create country specific versions of DemoForm_fr.properties file for France and French-speaking Canada. The country specific variant of the properties file contains only those keys for which the translation varies locally in each country.While creating country specific properties file such as DemoForm_fr_FR.properties and DemoForm_fr_CA.properties, it is better to create the DemoForm_fr_FR.properties and do all the translations. Then copy the latter to DemoForm_fr_CA.properties and make the additional changes.Finally, in both DemoForm_fr_FR.properties and DemoForm_fr_CA.properties delete all the entries whose keys and values are identical to those in DemoForm_fr.properties.
• The keys are first resolved in country specific versions of the properties file such as DemoForm_fr_FR.properties and DemoForm_fr_CA.properties.
•
a. You can select both the base properties and your language specific properties file in Project Explorer and use Context Menu > Compare With > Each Other to open them side-by-side in the Property Compare editor.
b. Use theCopy All Non-Conflicting Changes or
Copy Current Change (From ... To ...) actions to add new keys and delete old keys from your localized version. For new keys and those with updated values you can provide a new translation.
You can use the Form.setLocale(String) and Form.getLocale() methods to change the locale settings of the form.
1. Create a new resource file, with the extension .properties, within the folder /<project>/Presentation Resources in the Project Explorer. (Note that this is unlike the base properties file, which is also contained in the Presentation Resources folder, but is within a sub-folder for resources specific to the form, a sub-folder named with the name of the form.)
2. Edit the properties file by adding key-value pairs in the format <key> = <value>, each on a separate line. For example:
3. Copy the new resource file and save it with the same name but with an underscore and the locale code added before the file extension. For instance, if you wish to create a French version of a properties file named myResources.properties, save the first file as myResources_fr.properties.
2. In the Properties view for the form, go to the Resources tab. Click the plus sign to add a resource, locate the new properties file you created in the Presentation Resources folder, and add it as a resource for the form.
You will add the new properties file as a form resource using the base name. The various localized versions, with the locale code appended to the file name (preceding the .properties extension) will be inferred from the base name, based on the user’s locale, at runtime.The properties file now appears as a resource in the Resources tab, identified by a name and path (URI). The Localized button is automatically selected for the properties file, indicating that the run time should search for localized copies to match the user’s locale.
3. In the Properties view for the text control, give the control a name in the Name field on the General tab, for instance localizedText.
4. Go to the Rules tab in the Properties view for the button. Click the button to Define a new rule for the button that will be triggered when the button is clicked.
5.
6. Leave the values unchanged in the Rule: Pick Events dialog and click Next. This simply means the rule we create will be triggered when the button is clicked, which is the default event for buttons.
7. In the Define Actions dialog, click the plus sign to define a new action.
8. In the Add Action dialog, select the radio button Create a new action, and leave the radio button Script Action selected. Click Next to specify a script that defines the action.
9. Using the content assist pop-ups to ensure correct values, type the following line of script (assuming there is an item in your properties file whose key is mykey1 and whose value is My Key One):
10. Preview the form in the GWT Preview tab. Click the button on the form, and the text field’s label should say My Key One.
11.
![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |