Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to localize SmartGWT (i18n)?

    I am currently evaluating SmartGWT for our company's project. One of the requirements for our project is localization (i18n). I checked the reference for SmartClient 6.5.1 and found following code:

    Code:
    isc.RPCManager.addClassProperties({timeoutErrorMessage:"Custom Timeout Message"});
    However, I am not sure how to do the same thing with SmartGWT. Let's take ListGrid for example where ListGrid has sortFieldAscendingText and sortFieldDescendingText (i18nMessages). I can write following code:

    Code:
            final ListGrid countryGrid = new ListGrid();
            countryGrid.setSortFieldAscendingText("Asc Localize");
            countryGrid.setSortFieldDescendingText("Desc Localize");
    However, I can not localize ListGrid through the class level where I only need to set the localization property one time and subsequence of the initialization of the object will be automatically localized. By the way, GWT has really great localization mechanism where the localization property files can be defined. Is it possible that we can localize SmartGWT default components (ListGrid for example) through the property files? For example, based on the source code of ListGrid.js (the base of ListGrid of SmartGWT):
    Code:
    //> @attr ListGrid.sortFieldAscendingText (string : "Sort Ascending" : IRW)
    // If we're showing a +link{listGrid.showHeaderContextMenu,headerContextMenu} for this grid, this
    // attribute will be shown as the menu item title to sort a field in ascending order.
    // @group i18nMessages
    // @visibility external
    //<
    sortFieldAscendingText: "Sort Ascending",
    
    //> @attr ListGrid.sortFieldDescendingText (string : "Sort Descending" : IRW)
    // If we're showing a +link{listGrid.showHeaderContextMenu,headerContextMenu} for this grid, this
    // attribute will be shown as the menu item title to sort a field in descending order.
    // @group i18nMessages
    // @visibility external
    //<
    sortFieldDescendingText: "Sort Descending",
    Does SmartGWT provide a way that we can just modify property files and those default values will just be overwritten?

    Anyway, if we have to localize SmartGWT default components from object level, then it will be very inefficient from coding point of view.

    Thanks

    #2
    After evaluating the source code (ListGrid.java for example), I would assume that SmartGWT does not currently support GWT's i18n mechanism (or I should say that it will require individual developer to wire everything together). As for now, the easiest hack for me is to create an I18BeanFactory class which will initialize new widget instance (ListGrid for example), load constants, set all the properties (SortFieldAscendingText and SortFieldDescendingText for example), and then return the instance.

    However, it will be the best if SmartGWT can load those constants right from the constructor.
    Code:
        public ListGrid(JavaScriptObject jsObj) {
            super(jsObj);
            ListGridI18nConstants constants = (ListGridI18nConstants) GWT.create(ListGridI18nConstants.class);
            setSortFieldAscendingText(constants.getSortFieldAscendingText);
            setSortFieldDescendingText(constants.getSortFieldDescendingText);
            .
            .
            .
            .
        }
    reference:
    http://www.gwtapps.com/doc/html/com.google.gwt.i18n.client.Constants.html

    Thanks

    Comment


      #3
      ComboBoxItem.setLoadingDataMessage?

      How can I set (localize) the text that is shown while underlying dataSource is fetching data for ComboBoxItem?
      (For ListGrid there is the method setLoadingDataMessage; I couldn't find similar method for ComboBoxItem though.)

      EDIT:
      ...by setting your locale properly :)
      http://code.google.com/p/smartgwt/issues/detail?id=30
      Last edited by jzaruba; 30 Sep 2009, 05:58.

      Comment

      Working...
      X