Site logo

Locale independent strings

Sometimes, when writing a script, you may want to find out a locale independent string, say, to invoke a menu item. The problem is the menu name is different on various locales: for example:
In EnglishArticles
In GermanArtikel

A couple of methods come in handy in a such a situation:

translateKeyString() — translates a key string into localized form based on current application locale.

var myTranslateKeyString = app.translateKeyString("Unassigned InCopy Content");

findKeyStrings() — returns the locale-independent string(s) from the internal string localization database that correspond to the specified string (in the current locale):

var myFoundKeyString  = app.findKeyStrings("Unassigned InCopy Content"); 

Result:
$ID/UnassignedInCopy
$ID/Unassigned InCopy Content

Example of handling a locale-independent string:

main();

function main() {
	var myTranslatedKeyString = app.translateKeyString("$ID/[Normal Graphics Frame]");
	// ==> [Basic Graphics Frame]
	var myFoundKeyString  = app.findKeyStrings("[Basic Graphics Frame]");
	// ==> $ID/[Normal Graphics Frame]
}