Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Scripts in Localized InDesign : locale independent default names

Explorer ,
Jun 20, 2021 Jun 20, 2021

Copy link to clipboard

Copied

Hi All!

I am asking this question because I do not have enough experience with localized versions of InDesign, but at the moment my script needs to be used with such a version of InDesign.

In my script I need to use the default layer named "Layer 1". Localized versions of InDesign use different names.
When it comes to translating menu strings, one must use a localization-independent notation with the "$ID/" prefix.

The layer name is also numbered. How to do the right thing here?

 

 

app.translateKeyString("$ID/Layer 1")

 

 The same goes for the default style names....

Will it be correct to use such code? Is it possible to somehow find all the lines in independent localization?

 

TOPICS
Scripting

Views

118

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jun 21, 2021 Jun 21, 2021
Ok. That will work for you, if you do not want to add a document and read out the layer name when running your script on a localized version: app.translateKeyString("$ID/Placeholder for Level 1") But you cannot guess or calculate what the name is with a German InDesign in advance, if you open a document in an English version. For that you need access to a list of localized strings, I think. If you find a way to change the locale value of an installed InDesign by scripting, let me know. Thank...

Likes

Translate

Translate
Adobe Community Professional ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Hi vnh68,

interesting question.

 

I tried the following with my German InDesign 2021 where the "standard" layer in a new document is named "Ebene 1":

 

 

app.findKeyStrings("Ebene 1");
// Returned array contained one item that holds the string:
// "$ID/Placeholder for Level 1"

 

 

So I tried the following code to access the "standard" layer with that string:

 

var resultArray = app.findKeyStrings("Ebene 1");
// Returned array contained one item that holds the string:
// "$ID/Placeholder for Level 1"

var newDoc = app.documents.add();
var standardLayer = newDoc.layers.itemByName( resultArray[0] );
standardLayer.isValid;
// returns true

 

 

So, this question is answered.

String "$ID/Placeholder for Level 1" is the independent name for that layer.

 

If the layer was renamed perhaps and you want to add a new layer with the "standard" name you could do it like that:

 

app.documents[0].layers.add({ name : "$ID/Placeholder for Level 1"} )

 

Of course this code has to run on the localized version of InDesign.

 

What will not work the same way in this case is:

 

app.documents[0].layers.add();

 

It will add a new "standard" layer with a different name, perhaps "Ebene 2" with my German document.

 

What you cannot do without knowing the name of a "standard" layer:

Add the layer named in English when you running the script on a German InDesign.

However, now you know how to identify a standard name.

//EDIT: Wrong. See next post.

 

 

FWIW: Standard layer names are not renamed when you open a document in a different localized version of InDesign.

 

And perhaps you already guessed it now:

 

var resultArray = app.findKeyStrings("Ebene 2");
// Returned array contained one item that holds the string:
// "$ID/Placeholder for Level 2"

 

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

LATEST

Ok. That will work for you, if you do not want to add a document and read out the layer name when running your script on a localized version:

app.translateKeyString("$ID/Placeholder for Level 1")

 

But you cannot guess or calculate what the name is with a German InDesign in advance, if you open a document in an English version. For that you need access to a list of localized strings, I think. If you find a way to change the locale value of an installed InDesign by scripting, let me know.

 

Thanks,
Uwe Laubender

( ACP )

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines