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());



As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles