
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Language localization in Javacript
> var english = new Object ();
> english.l00001 = "hello";
> english.l00002 = "goodbye";
> var japanese = new Object ()
> japanese.l00001 = "今日は";
> japanese.l00002 = "サヨナラ";
>
> ... but I just can't think of how I switch them up at the point when I
> want to display one or the other, because the switch involves changing
> the name of the variable being called.
var x=(language=="en"?english:japanese);
...
alert(x.l00001);
I.e. you set a reference variable to point to one language or the other.
Then you use that reference variable to get at your strings.
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
Home |
Main Index |
Thread Index