Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Explain basic I18N better

...

Code Block
  add( new Label( "page.label", new PropertyModel( this, "propertyName" ) );

which accesses a property from the page class. No problem.

So, what do we do if we want to i18nise this label?

...

Code Block
  if( getSession().getLocale h1.  Locale.ENGLISH )
    add( new Label( "page.label", new PropertyModel( this, "enPropertyName" ) );
  else if( getSession().getLocale  Locale.FRENCH )
    add( new Label( "page.label", new PropertyModel( this, "frPropertyName" ) );
  ...

which is a very bad idea!

Rather, use the support provided by Wicket. By setting up properties files for your pages, wicket will take care of the details for you. So, you would set up files like so:

Panel

MyPage_en.properties
page.label=hello

MyPage_fr.properties
page.label=salut

etc.

you would set up files like so:

Panel

MyPage.properties
page.label=hello

MyPage_fr.properties
page.label=salut

etc.

MyPage.properties is used for the default language for the website, MyPage_xx.properties is used for other languages, replacing xx by the language code.

You can then activate the properties files by Java code such as this:

Code Block

  add( new Label( "page.label", new ResourceModel( "page.label" ) );

However, Wicket provides a much quicker and simpler solution with a dedicated tag for the html, that means there is no Java code to write at all:

Code Block
html
html

  <wicket:message key="page.label">Default label</wicket:message>

i18n of Entire Pages

To i18nise an entire page, it's the same simple approach as for a label. We simply write entire pages with the locale name appended to the page name:

...

Panel

<a wicket:id="links.acme">Ã?£?ââ?¬Å?"Ã?£?Ã?¡Ã?£ââ?¬Å¡Ã¢â?¬Â°</a>Ã?£?Ã?«Ã?£?ââ?¬?Ã?¨Ã?¦Ã?§Ã?£??Ã?£?Ã? Ã?£?ââ?¬Â¢Ã?£?ââ?¬Å¾.

...