Page 1 of 1

Changing lang dynamically ...

Posted: Fri 31 Jan 2020 1:02 am
by beteljuice
The beteljuice has cause to investigate how change gauges language on-demand.

I'm using changeLang(res); where res = "LANG." + ??;

console.log() confirms action taken and res value.

Everything folds and comes back undefined ....

Edit: Ah .... It has to be without quotes ...

How do I code for that ???

Edit #2: Got it working with eval() .. changeLang(eval(res));

... but I thought that had been depreciated years ago ???

Re: Changing lang dynamically ...

Posted: Fri 31 Jan 2020 3:04 pm
by mcrossley
Rather than using text for the "LANG.xxx", use

Code: Select all

changeLang(LANG["??"]);

Re: Changing lang dynamically ...

Posted: Fri 31 Jan 2020 3:33 pm
by beteljuice
An object[array] :groan:

I must try and get some sleep this year ...

Re: Changing lang dynamically ...

Posted: Fri 31 Jan 2020 3:41 pm
by mcrossley
Well it is an Object rather than an array, but JavaScript allows you to use array notation on objects as well as dot - probably for just this usage.