samedi 5 juillet 2014

Simple localisation using ternary operator

Hi,

I have a requirement to localise a number of UI components in a different language other than English.


I was wondering if there is an easy way to implement the ternary operator in order to determine which text should be shown the user based on a variable that I use to store the users choice of language.


For example



Code:



//Config
title: this.selectedLanguage() == 'English' ? 'ENGLISH_TITLE' : 'OTHER_LANGUAGE_TITLE';

I tried the above but it did not work and prevented the application from loading, however if you use integer values that do not require evaluation then this approach was more fortuitous.

I have also looked at UX.localeManager but this seems like a lot of overhead?





Aucun commentaire:

Enregistrer un commentaire