LocaleSession demo

Description
This page displays the LocaleSession usage.
You can switch your language by clicking any of the link. The language will be stored in session.
Notice : This feature have to be specifically enabled in your Module class. Have a look at the documentation for more details.


In Action
Switch language to "fr"
Switch language to "en"

Message : Hello to you !!


TML Source code

		<t:actionlink t:id="fr">Switch language to "fr"</t:actionlink><br/>
		
		<t:actionlink t:id="en">Switch language to "en"</t:actionlink><br/><br/>
		
 	Message : ${message:hello} !!
	



Java code

	public class Example1
	{
	    @Inject
	    private LocaleSessionService localeSessionService;
	
	    void onActionFromFr()
	    {
	        localeSessionService.setLocale(Locale.FRANCE);
	    }
	
	    void onActionFromEn()
	    {
	        localeSessionService.setLocale("en");
	    }
	}
	
	Module class : 
	public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
    {
       	...
        configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en,fr");
        ...
    }
    

Notice
These keys are defined in several i18n property file :

Example1.properties

hello=Default language, nothing set
Example1_fr_FR.properties

hello=Bonjour ?? vous
Example1_en.properties

hello=Hello to you !