After some investigation, it turns out things are actually behaving as they should in our testing, and problem you're experiencing is most likely a configuration error. We apologize for the conflicting information.
To show you a test case where this is behaving as it should - let's start with the "BuiltInDS" sample from the SmartGWTEE 4.1p package.
For completeness, let's show both framework localization and localization of custom values within the .ds.xml file - in this case the error message for a validator.
Everything we're doing here is covered in the javadoc - see the Framework localization overview and the DataSource localization overview. (We're not getting into other application-level localization, but for completeness we recommend standards GWT localization techniques as discussed here)
To start with let's modify the BuiltInDS application to enable framework localization:
- modify the BuiltInDS.gwt.xml file to enable the "fr" locale as follows:
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd"> <module rename-to="builtinds"> <inherits name='com.google.gwt.user.User'/> <inherits name="com.smartgwt.tools.SmartGwtTools"/> <inherits name="com.smartgwtee.tools.Tools"/> <inherits name="com.smartgwtee.SmartGwtEE"/> <entry-point class='com.smartgwt.sample.client.BuiltInDS'/> <extend-property name="locale" values="fr"/> </module>
Now if you load the application, you'll see the empty message before you select a DataSource from the grid on the left is localized to French.
If you select "Office Supplies" and then click the "New" button, followed by the "Save" button without entering any details, you'll see the validation error displayed next to the "Item" item is localized ("Champs Requis" rather than "Field is Required").
Now lets add a validator to the xml file with a custom error message, and localize that:
- create a new pair of .properties files in your source tree.
We created "i18nMessages.properties", containing the following:
Code:
#custom properties file for 'i18nMessages' validator_requiredField = Required Field Custom
Code:
#custom properties file for 'i18nMessages' - french version validator_requiredField = Champs Requis Personnailise
Now modify the supplyItem.ds.xml file to include the "fmt" tags necessary to pick up this locale information. Note the <fmt:bundle... > tag refers to the correct location for the localized files:
Code:
<DataSource xmlns:fmt="WEB-INF/" ID="supplyItem" serverType="sql" tableName="supplyItem" titleField="itemName" testFileName="/examples/shared/ds/test_data/supplyItem.data.xml" dbImportFileName="/examples/shared/ds/test_data/supplyItemLarge.data.xml" > <fmt:bundle basename="com.smartgwt.sample.client.i18nMessages" /> <fields> <field name="itemID" type="sequence" hidden="true" primaryKey="true"/> <field name="itemName" type="text" title="Item" length="128"> <validators> <validator type="required" requiresServer="true"> <errorMessage><fmt:message key="validator_requiredField"/> </errorMessage> </validator> </validators> </field> <field name="SKU" type="text" title="SKU" length="10" required="true"/> <field name="description" type="text" title="Description" length="2000"/> <field name="category" type="text" title="Category" length="128" required="true" foreignKey="supplyCategory.categoryName"/> <field name="units" type="enum" title="Units" length="5"> <valueMap> <value>Roll</value> <value>Ea</value> <value>Pkt</value> <value>Set</value> <value>Tube</value> <value>Pad</value> <value>Ream</value> <value>Tin</value> <value>Bag</value> <value>Ctn</value> <value>Box</value> </valueMap> </field> <field name="unitCost" type="float" title="Unit Cost" required="true"> <validators> <validator type="floatRange" min="0" errorMessage="Please enter a valid (positive) cost"/> <validator type="floatPrecision" precision="2" errorMessage="The maximum allowed precision is 2"/> </validators> </field> <field name="inStock" type="boolean" title="In Stock"/> <field name="nextShipment" type="date" title="Next Shipment"/> </fields> </DataSource>
Now modify the bootstrap file (BuiltInDS.html) to actually apply the french locale to the dataSource when loading it, changing this:
Code:
<!--load the datasources--> <script src="builtinds/sc/DataSourceLoader?dataSource=supplyItem,animals,employees"></script>
Code:
<!--load the datasources--> <script src="builtinds/sc/DataSourceLoader?dataSource=supplyItem,animals,employees&locale=fr"></script>
Now you'll see the modified, localized error message "Champs Requis Personnailise'
Please let us know if this doesn't fully resolve this issue for you
Thanks
Isomorphic Software
Leave a comment: