General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Get current localization of XMetaL Author from JScript
-
FloPes December 20, 2013 at 7:17 am
Get current localization of XMetaL Author from JScript
December 20, 2013 at 7:17 amParticipants 1Replies 2Last Activity 9 years, 1 month agoIs 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?
Derek Read December 20, 2013 at 10:47 pm
Reply to: Get current localization of XMetaL Author from JScript
December 20, 2013 at 10:47 pmThere 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_LanguageYou 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.
Derek Read December 20, 2013 at 11:04 pm
Reply to: Get current localization of XMetaL Author from JScript
December 20, 2013 at 11:04 pmNote 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).
-
AuthorPosts
- You must be logged in to reply to this topic.