Pages: 1
Print
Author Topic: Get current localization of XMetaL Author from JScript  (Read 2272 times)
FloPes
Member

Posts: 1


« on: December 20, 2013, 01:17:42 AM »

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?
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: December 20, 2013, 04:47:02 PM »

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_MACHINE\SOFTWARE\SoftQuad\XMetaL 7.0\Install_Language
HKEY_LOCAL_MACHINE\SOFTWARE\SoftQuad\XMetaL 8.0\Install_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);

I believe standard two letter localization values are used such as EN, DE, FR and JP.
« Last Edit: December 20, 2013, 04:55:14 PM by Derek Read » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #2 on: December 20, 2013, 05:04:18 PM »

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_MACHINE\SOFTWARE\Wow6432Node\SoftQuad\XMetaL <version>\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).
« Last Edit: December 20, 2013, 05:38:08 PM by Derek Read » Logged
Pages: 1
Print
Jump to: