1 person found this helpful
An alternative approach:
Instead of setting up two translation environments, try app.translateKeyString() to access your plugin's localized strings.
There is also app.findKeyStrings() to if you're not sure about how the key string ends up in JS - it should yield a "$ID/" prefix plus your plugin string (before translation).
Thank you John
Thank you Dirk
Just trying to go with your suggestion with using app.translateKeyString() for localization in my script files.
I'm not clear about the the value I pass to this function.... if I have translation for 3 .fr files (3 languages) and I want to display a simple string in alert in my Scrip file, which I defined the keys,values for the string in 3 .fr files as:
kMyAlertStringKey, "an english string",
kMyAlertStringKey, "a french string",
kMyAlertStringKey, "a german string",
I should call this in the original script file like:
var myLocalizedString = app.translateKeyString( '$ID/an english string' );
P.S. I'm in default us english version
(Just a note aside.)
If the native localization module is an issue, I suggest you an alternative approach:
Use the actual resulting value of the preprocessor name kMyAlertStringKey!
That is the string also produced in C++ if you specify to not translate.
var kMyAlertStringKey = "0x12345myAlStr" // your plugin prefix plus your internal key string as combined in that define statement in the id.h .
app.translateKeyString("$ID/"+kMyAlertStringKey) should then yield the english string.
To find the actual argument for other strings, using your english version of InDesign:
app.findKeyStrings("an english string") should yield an array with that "$ID/0x122345myAlStr"
How can I access to my actual resulting value of the preprocessor kMyAlertStringKey in the scrip file?
assume in id.h file I have:
#define kMyAlertStringKey kmyPluginStringPrefix "kMyAlertStringKey"
Itried to get it by app.findKeyStrings() like this:
var theStr = app.findKeyStrings('an english string.');
When I print it, i'll see resulting string(0x12345myAlStr) but when I pass it to app.translateKeyString() like this:
var theSecStr = app.translateKeyString( theStr);
var theSecStr = app.translateKeyString( "$ID/" + theStr); but still the same error.
am I doing right with this approach?
how would be the perfomance(speedwise) compare to other approach for localization in this approach?
You're fooled by a bug of ESTK which sometimes decides to omit the square brackets when displaying arrays.
var theStrArray = app.findKeyStrings('an english string.');
var theStr = theStrArray;
then just continue as you did.
Sorry, I'll be kindof offline for the next days, only have an iPad here at slowest speed, if any.
Well, I think I found out the answer to my first part, I just need to make the key by concating strings ( myprefixPlugin + myStringKey)
Would this be enough to work for other language as well without using app.findKey()?