Mailing List Archive


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

Re: [tlug] Language localization in Javacript




Hi Martin,


On 28/09/11 16:40, Martin G wrote:
var x=(language=="en"?english:japanese);

However, I've never used this syntax before and I'm having a hard time
extending it. I looked up Javascript and colons on Google, but all I
saw was how it's used in JSON syntax, which doesn't seem to be how
it's used here.


If you're talking about the ? and : combination, it is a pair of operators that appears in several languages (not just JavaScript). I personally rarely use it since it is difficult to extend ... it can be difficult to find on search engines, of course.

Here is the description in Wikipedia:

http://en.wikipedia.org/wiki/%3F:


How would I set up a conditional for three or more possible languages?
I'm likely to have a dozen or more languages available for this
application.


I don't know JavaScript so I can't help you with the specific language, but in general, you would probably have to expand a ?: to a series of if...elseif...else statements. If the language supports it, then some kind of switch/case statements would be ideal.

Hope this helps!

Ray




Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links