Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Language localization in Javacript



On Sep 27, 2011, at 7:31 PM, Martin G wrote:
> ... 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.
> There must be a simple way to do this...?


I think you may want to do this with something server-side in addition to javascript,
but if it's the only way you can do like this :

switch (navigator.language.substr(0, 2)) {
  case "en" :
    document.writeln("Hello.");
    break;
  case "ja" :
    document.writeln("こんにちは.");
    break;
}

Cheers,
Lewske Wada
Web: http://run.sh/
Email: ryu@example.com
Facebook: Lewske Wada
Skype: lewske




Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links