Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.4.0 (build 3064) - 19 February 2020.
    Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

    See the Wiki for downloading either version.

    Changing lang dynamically ...

    Discussion of Mark Crossley's HTML5/Javascript gauges

    Moderator: mcrossley

    Post Reply
    User avatar
    beteljuice
    Posts: 2821
    Joined: Tue 09 Dec 2008 1:37 pm
    Weather Station: None !
    Operating System: ex XP SP3 - now W10 laptop grr
    Location: Dudley, West Midlands, UK

    Changing lang dynamically ...

    Post by beteljuice » Fri 31 Jan 2020 1:02 am

    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 ???
    Image
    ......................Imagine, what you will KNOW tomorrow !

    User avatar
    mcrossley
    Posts: 5997
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2
    Operating System: Stretch Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

    Re: Changing lang dynamically ...

    Post by mcrossley » Fri 31 Jan 2020 3:04 pm

    Rather than using text for the "LANG.xxx", use

    Code: Select all

    changeLang(LANG["??"]);

    User avatar
    beteljuice
    Posts: 2821
    Joined: Tue 09 Dec 2008 1:37 pm
    Weather Station: None !
    Operating System: ex XP SP3 - now W10 laptop grr
    Location: Dudley, West Midlands, UK

    Re: Changing lang dynamically ...

    Post by beteljuice » Fri 31 Jan 2020 3:33 pm

    An object[array] :groan:

    I must try and get some sleep this year ...
    Image
    ......................Imagine, what you will KNOW tomorrow !

    User avatar
    mcrossley
    Posts: 5997
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2
    Operating System: Stretch Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

    Re: Changing lang dynamically ...

    Post by mcrossley » Fri 31 Jan 2020 3:41 pm

    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.

    Post Reply