I've been trying to get localization (i18n) to work on the DataSource field titles in a DataSource ds.xml files following the steps documented in the SmartClient reference on DataSource localization that been cited as the how-to in other forum threads. I think I am not understanding a key concept since I've not gotten it to work.
I am using SmartGWT PowerEdition 2.3 (SC_SNAPSHOT-2010-09-04/PowerEdition Deployment (built 2010-09-04)) with Eclipse 3.5 running in development mode with GWT 2.0.4 plugins.
I can get the GWT approach to localization to work, but I'd prefer to get the localization in the DataSource for the field titles. What am I missing or doing incorrectly? I am guessing that I'm not providing English and Spanish language bundles needed for the translation and it unfortunately will not be using the same i18n mechanism that GWT is using. I've not found hints yet what I should to create the appropriate bundles or where to place them.
I added the "/shared/ds/*" to the jsp-config in the web.xml, snippet:
This is the PING.ds.xml:
Note, I do not have a WEB-INF/fmt.tld file. Should I have this file and is it the one from the jakarta-taglibs-standard-1.1.2?
This is the html page for the Ping RIA:
Also note, I'm trying to do this from an html file not a jsp file. Is this translation possible using the DataSourceLoader script method?
This is the Ping.gwt.xml:
This is the GWT localization code:
ClientConstants_es.properties:
And the code for Ping.java:
Note, I've commented out the GWT localization that I have working in Ping.java since I am trying to get the embedded DataSource localization method working.
Also, is there a working example that I missed in the showcase for localization of ds.xml files that I overlooked? If there is a demo project that I can look at it would be really helpful for my understanding of this task.
I am using SmartGWT PowerEdition 2.3 (SC_SNAPSHOT-2010-09-04/PowerEdition Deployment (built 2010-09-04)) with Eclipse 3.5 running in development mode with GWT 2.0.4 plugins.
I can get the GWT approach to localization to work, but I'd prefer to get the localization in the DataSource for the field titles. What am I missing or doing incorrectly? I am guessing that I'm not providing English and Spanish language bundles needed for the translation and it unfortunately will not be using the same i18n mechanism that GWT is using. I've not found hints yet what I should to create the appropriate bundles or where to place them.
I added the "/shared/ds/*" to the jsp-config in the web.xml, snippet:
Code:
<jsp-config> <!-- Isomorphic JSP tags --> <taglib> <taglib-uri>isomorphic</taglib-uri> <taglib-location>/WEB-INF/iscTaglib.xml</taglib-location> </taglib> <!-- For I18N of ds.xml fields, etc. --> <jsp-property-group> <url-pattern>/shared/ds/*</url-pattern> </jsp-property-group> </jsp-config>
Code:
<!-- <%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %> --> <DataSource xmlns:fmt="urn:jsptld:/WEB-INF/fmt.tld" schema="PING" dbName="Oracle" tableName="PING" ID="PING" serverType="sql" > <fields> <field sequenceName="PING_SEQ" primaryKey="true" name="id" type="sequence" hidden="true"></field> <field name="name" length="51" type="text"> <title><fmt:message key="ping_ds_field_name" /></title> <validators> <validator type="isUnique" requiresServer="true" /> </validators> </field> <field name="other" length="21" type="text"> <title><fmt:message key="ping_ds_field_other" /></title> </field> </fields> <operationBindings> <operationBinding operationType="fetch" > <orderClause> UPPER(ping.PING.name) </orderClause> </operationBinding> </operationBindings> </DataSource>
This is the html page for the Ping RIA:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="gwt:property" content="locale=es"> <title>Ping</title> <script>var isomorphicDir = "Ping/sc/";</script> <script type="text/javascript" language="javascript" src="Ping/Ping.nocache.js"></script> </head> <body> <!--load the datasources--> <script src="Ping/sc/DataSourceLoader?dataSource=PING"></script> <!-- OPTIONAL: include this if you want history support --> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> </body> </html>
Also note, I'm trying to do this from an html file not a jsp file. Is this translation possible using the DataSourceLoader script method?
This is the Ping.gwt.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.4//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module rename-to="Ping"> <inherits name='com.google.gwt.user.User'/> <inherits name="com.smartgwtpower.SmartGwtPower"/> <entry-point class='com.smartgwt.sample.client.Ping'/> <extend-property name="locale" values="es"/> </module>
Code:
package com.smartgwt.sample.client; import com.google.gwt.i18n.client.Constants; public interface ClientConstants extends Constants { @DefaultStringValue("Clear") String clear(); @DefaultStringValue("New") String _new(); @DefaultStringValue("Save") String save(); @DefaultStringValue("Name") String ping_ds_field_name(); @DefaultStringValue("Other") String ping_ds_field_other(); }
Code:
clear = Limpiar _new = Crear save = Guardar ping_ds_field_name = Nombre ping_ds_field_other = Suplemento
Code:
package com.smartgwt.sample.client; import java.util.ArrayList; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VStack; public class Ping implements EntryPoint { private ClientConstants constants = GWT.create(ClientConstants.class); private ListGrid grid; private DynamicForm form; private IButton saveBtn; private IButton newBtn; public void onModuleLoad() { Canvas mainCanvas = new Canvas(); mainCanvas.setHeight100(); mainCanvas.setWidth100(); mainCanvas.setBackgroundColor("green"); DataSource ds = DataSource.get("PING"); VStack vstack = new VStack(); vstack.setLeft(10); vstack.setTop(10); vstack.setWidth("80%"); vstack.setHeight("80%"); vstack.setMembersMargin(10); grid = new ListGrid(); grid.setDataSource(ds); grid.setWidth(300); grid.setHeight(200); grid.addRecordClickHandler(new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { Record record = event.getRecord(); form.editRecord(record); form.enable(); saveBtn.enable(); newBtn.disable(); } }); // Add for I18N // ListGridField nameField = new ListGridField("name", constants.ping_ds_field_name()); // ListGridField otherField = new ListGridField("other", constants.ping_ds_field_other()); // grid.setFields(nameField, otherField); grid.fetchData(); vstack.addMember(grid); form = new DynamicForm(); form.setDataSource(ds); form.setNumCols(2); form.setAutoFocus(false); form.disable(); // Add for I18N // ArrayList<FormItem> fields = new ArrayList<FormItem>(); // TextItem name = new TextItem("name", constants.ping_ds_field_name()); // fields.add(name); // TextItem other = new TextItem("other", constants.ping_ds_field_other()); // fields.add(other); // form.setFields(fields.toArray(new FormItem[fields.size()])); vstack.addMember(form); HLayout hLayout = new HLayout(10); hLayout.setMembersMargin(10); hLayout.setHeight(22); saveBtn = new IButton(constants.save()); saveBtn.disable(); saveBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { form.saveData(); } }); hLayout.addMember(saveBtn); newBtn = new IButton(constants._new()); newBtn.enable(); newBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { form.enable(); form.editNewRecord(); saveBtn.enable(); newBtn.disable(); } }); hLayout.addMember(newBtn); IButton clearBtn = new IButton(constants.clear()); clearBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { form.disable(); form.clearValues(); saveBtn.disable(); newBtn.enable(); } }); hLayout.addMember(clearBtn); vstack.addMember(hLayout); mainCanvas.addChild(vstack); mainCanvas.draw(); } }
Also, is there a working example that I missed in the showcase for localization of ds.xml files that I overlooked? If there is a demo project that I can look at it would be really helpful for my understanding of this task.
Comment