General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Get current localization of XMetaL Author from JScript

  • FloPes

    Get current localization of XMetaL Author from JScript

    Participants 1
    Replies 2
    Last Activity 8 years, 9 months ago

    Is there a way to get the current localization that XMetaL Author (7.0.0.111) is running from JScript, so I can use it in my macros to determine in what language I should display user messages?

    Reply

    Derek Read

    Reply to: Get current localization of XMetaL Author from JScript

    There is no API for this, but starting with version 7.0 the following key is set in the registry for the particular version of XMetaL Author Essential or XMetaL Author Enterprise you have installed.

    HKEY_LOCAL_MACHINESOFTWARESoftQuadXMetaL 7.0Install_Language
    HKEY_LOCAL_MACHINESOFTWARESoftQuadXMetaL 8.0Install_Language

    You can use the standard Windows “WScript.Shell” ActiveX object to read from the registry, so a script similar to the following JScript example should give you what you need:

    [code]//XMetaL Script Language JScript:
    function registryReadKey(regKey) {
    try {
    var wShell = new ActiveXObject(“WScript.Shell”);
    var keyVal = wShell.RegRead(regKey);
    wShell = null;
    return keyVal;
    }
    catch(e) {
    //no value set or something else went wrong, fail silently
    }
    }
    var xmVersion = Application.VersionNumber;
    var xmLocale = registryReadKey(“HKEY_LOCAL_MACHINE\SOFTWARE\SoftQuad\XMetaL ” + xmVersion + “\Install_Language”);
    Application.Alert(xmLocale);[/code]

    I believe standard two letter localization values are used such as EN, DE, FR and JP.

    Reply

    Derek Read

    Reply to: Get current localization of XMetaL Author from JScript

    Note that on a 64-bit installation of Windows there will likely be an additional key, used by Microsoft's “Windows on Windows” layer (WOW64), like this:

    HKEY_LOCAL_MACHINESOFTWAREWow6432NodeSoftQuadXMetaL Install_Language

    …but Windows magically redirects the call from RegRead to the right Wow6432Node subkey, so the script should work regardless of processor architecture (which makes sense because this stuff is supposed to be automatically handled by Windows when running 32-bit applications).

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support