GWT: i18n internationalization

To create an internationalization functionality in a GWT application: 1. Create an Interface for all front-end strings:

package com.ucc.csd.client;

import com.google.gwt.i18n.client.Constants;

public interface I18nConstants extends Constants

{

    String imageViewPath();

}

2. Create a "i18nConstants.properties" file in the client package (com.xyz.zyx.client)

# PROD

#imageViewPath = http://communitysportsdesk.com/csd_images/ 

# UAT

#imageViewPath = http://64.191.235.56/csd_images/ 

# Uki

imageViewPath = http://localhost:8282/csd_images/

# Zainab, Trevor, Phil

#imageViewPath = http://localhost:8080/csd_images/

3. Create a class variable for the i18n Interface:

private I18nConstants i18n;

4. Generate GWT implementation for it, in the class constructor:

i18n = (I18nConstants) GWT.create(I18nConstants.class);

5. Call it as needed:

setImageViewPath(i18n.imageViewPath());

No comments:

Post a Comment