Skip to main content
December 9, 2011
Answered

appliedLanguage > List of available languages

  • December 9, 2011
  • 3 replies
  • 5617 views

I was searching for a javascript for Indesign that changes the language of all paragraph styles in a document to a certain language.

http://forums.adobe.com/thread/928736?tstart=0

helped me, BUT: is there a complete list of languages?

For example in my mother tongue, German, there's Swiss spelling, but also different options for the German German, e.g. Spelling reform 2006. How can I adress these specific variants?

Thank you in advance,

Stef

e. There's a script telling you the used language.

// languages.js

//

var myLan = app.languagesWithVendors;

var myLanNames = [];

for (oneLan=1; oneLan < myLan.length; oneLan++){

myLanNames.push(myLan[oneLan].name);

}

var myText = myLanNames.sort();

myText = myText.join("\n");

// Bildschirmausgabe

alert("Languages\n" + myText)

// Dateiausgabe

doExport(myText);

function doExport(myData){

myPath = '~/Desktop/'; // Pfad für MAC; 

//myPath = '/c/'; //  Pfad für Win 

myTXT_File = 'InDesignSprachen.txt'; // Dateiname 

myCreator = "R*ch"; // relevant für MAC 

myType = "TEXT"; // relevant für MAC 

 

myFile = new File( myPath + myTXT_File ); // neue Datei 

myFile.open( 'w', myType, myCreator );  

myFile.writeln( myData );  

myFile.close();

}

This specific script is telling me "Deutsch: Neue Rechtschreibung 2006". But if I try this for the language change script, it won't work. It asks for an english term, as "French", "Spanish", and "Italian" are working.

edit 2: "German: Reformed" brings you to "Neue Rechtschreibung 1996". The first instance of the spelling reform. But what about 2006? Thank you, Germany, for that spelling mess.

Correct answer Marc Autret

This is a complicated topic, because when you set myText.appliedLanguage with a direct String, a localized language name is expected—and myText.appliedLanguage.name returns a localized language name—but languagesWithVendors.itemByName() and languages.itemByName() seem to expect the English key of the language. Nevertheless this is not exactly what it happens. For example, the following code will work:

   myText.appliedLanguage = app.languagesWithVendors.itemByName("German: Swiss"); // OK

but the following will not:

   myText.appliedLanguage = app.languagesWithVendors.itemByName("German: Swiss 2006 Reform"); // WON'T WORK

Now, if you try this:

   myText.appliedLanguage = app.languagesWithVendors.itemByName("de_CH_2006"); // OK!!

this gives the expected result!

Why? Because, under the hood, the itemByName() method seems to use an internal translated key string! It mutely appends the $ID/ prefix to the supplied argument, so the above statement is equivalent to:

   myText.appliedLanguage = "$ID/de_CH_2006";

which also works!

Now the whole question is: how to know the secret key strings used by InDesign to deal with language names?

Here is the trick:

var a = app.languagesWithVendors.everyItem().name,

    i = a.length;

while( i-- ) a = a + " => " + app.findKeyStrings(a).join('  OR  ');

alert( a.sort().join('\r') );

And the result:

Bulgarian => $ID/Bulgarian  OR  $ID/IDX_Bulgarian

Catalan => $ID/Catalan

Croatian => $ID/Croatian  OR  $ID/IDX_Croatian

Czech => $ID/Czech  OR  $ID/IDX_Czech

Danish => $ID/Danish

Dutch: 2005 Reform => $ID/nl_NL_2005

Dutch: Old Rules => $ID/Dutch

English: Canadian => $ID/English: Canadian

English: UK => $ID/English: UK

English: USA => $ID/English: USA

English: USA Legal => $ID/English: USA Legal

English: USA Medical => $ID/English: USA Medical

Estonian => $ID/IDX_Estonian  OR  $ID/Estonian

Finnish => $ID/Finnish

French => $ID/French

French: Canadian => $ID/French: Canadian

German: 1996 Reform => $ID/German: Reformed

German: 2006 Reform => $ID/de_DE_2006

German: Old Rules => $ID/German: Traditional

German: Swiss 2006 Reform => $ID/de_CH_2006

German: Swiss => $ID/German: Swiss

Greek => $ID/kWRIndexGroup_GreekAlphabet  OR  $ID/Greek  OR  $ID/Greek Mode

Hungarian => $ID/Hungarian  OR  $ID/IDX_Hungarian

Italian => $ID/Italian

Latvian => $ID/IDX_Latvian  OR  $ID/Latvian

Lithuanian => $ID/IDX_Lithuanian  OR  $ID/Lithuanian

Norwegian: Bokmål => $ID/Norwegian: Bokmal

Norwegian: Nynorsk => $ID/Norwegian: Nynorsk

Polish => $ID/Polish  OR  $ID/IDX_Polish

Portuguese => $ID/Portuguese

Portuguese: Brazilian => $ID/Portuguese: Brazilian

Romanian => $ID/IDX_Romanian  OR  $ID/Romanian

Russian => $ID/Russian  OR  $ID/IDX_Russian

Slovak => $ID/Slovak  OR  $ID/IDX_Slovak

Slovenian => $ID/Slovenian  OR  $ID/IDX_Slovenian

Spanish => $ID/IDX_Spanish  OR  $ID/Spanish: Castilian  OR  $ID/Spanish

Swedish => $ID/Swedish

Turkish => $ID/IDX_Turkish  OR  $ID/Turkish

Ukrainian => $ID/IDX_Ukrainian  OR  $ID/Ukrainian

[No Language] => $ID/[No Language]

@+

Marc

3 replies

December 14, 2011

Thank you both, Hakenlid and Marc. You're awesome to me, who is absolutely newbie in that depth of indesign.

Marc Autret
Marc AutretCorrect answer
Legend
December 9, 2011

This is a complicated topic, because when you set myText.appliedLanguage with a direct String, a localized language name is expected—and myText.appliedLanguage.name returns a localized language name—but languagesWithVendors.itemByName() and languages.itemByName() seem to expect the English key of the language. Nevertheless this is not exactly what it happens. For example, the following code will work:

   myText.appliedLanguage = app.languagesWithVendors.itemByName("German: Swiss"); // OK

but the following will not:

   myText.appliedLanguage = app.languagesWithVendors.itemByName("German: Swiss 2006 Reform"); // WON'T WORK

Now, if you try this:

   myText.appliedLanguage = app.languagesWithVendors.itemByName("de_CH_2006"); // OK!!

this gives the expected result!

Why? Because, under the hood, the itemByName() method seems to use an internal translated key string! It mutely appends the $ID/ prefix to the supplied argument, so the above statement is equivalent to:

   myText.appliedLanguage = "$ID/de_CH_2006";

which also works!

Now the whole question is: how to know the secret key strings used by InDesign to deal with language names?

Here is the trick:

var a = app.languagesWithVendors.everyItem().name,

    i = a.length;

while( i-- ) a = a + " => " + app.findKeyStrings(a).join('  OR  ');

alert( a.sort().join('\r') );

And the result:

Bulgarian => $ID/Bulgarian  OR  $ID/IDX_Bulgarian

Catalan => $ID/Catalan

Croatian => $ID/Croatian  OR  $ID/IDX_Croatian

Czech => $ID/Czech  OR  $ID/IDX_Czech

Danish => $ID/Danish

Dutch: 2005 Reform => $ID/nl_NL_2005

Dutch: Old Rules => $ID/Dutch

English: Canadian => $ID/English: Canadian

English: UK => $ID/English: UK

English: USA => $ID/English: USA

English: USA Legal => $ID/English: USA Legal

English: USA Medical => $ID/English: USA Medical

Estonian => $ID/IDX_Estonian  OR  $ID/Estonian

Finnish => $ID/Finnish

French => $ID/French

French: Canadian => $ID/French: Canadian

German: 1996 Reform => $ID/German: Reformed

German: 2006 Reform => $ID/de_DE_2006

German: Old Rules => $ID/German: Traditional

German: Swiss 2006 Reform => $ID/de_CH_2006

German: Swiss => $ID/German: Swiss

Greek => $ID/kWRIndexGroup_GreekAlphabet  OR  $ID/Greek  OR  $ID/Greek Mode

Hungarian => $ID/Hungarian  OR  $ID/IDX_Hungarian

Italian => $ID/Italian

Latvian => $ID/IDX_Latvian  OR  $ID/Latvian

Lithuanian => $ID/IDX_Lithuanian  OR  $ID/Lithuanian

Norwegian: Bokmål => $ID/Norwegian: Bokmal

Norwegian: Nynorsk => $ID/Norwegian: Nynorsk

Polish => $ID/Polish  OR  $ID/IDX_Polish

Portuguese => $ID/Portuguese

Portuguese: Brazilian => $ID/Portuguese: Brazilian

Romanian => $ID/IDX_Romanian  OR  $ID/Romanian

Russian => $ID/Russian  OR  $ID/IDX_Russian

Slovak => $ID/Slovak  OR  $ID/IDX_Slovak

Slovenian => $ID/Slovenian  OR  $ID/IDX_Slovenian

Spanish => $ID/IDX_Spanish  OR  $ID/Spanish: Castilian  OR  $ID/Spanish

Swedish => $ID/Swedish

Turkish => $ID/IDX_Turkish  OR  $ID/Turkish

Ukrainian => $ID/IDX_Ukrainian  OR  $ID/Ukrainian

[No Language] => $ID/[No Language]

@+

Marc

Peter Kahrel
Community Expert
Community Expert
December 10, 2011

Nice trick!

Peter

December 9, 2011

For international versions of InDesign it is better to use ID instead of name to select a language. This will change the langage in all stories to German 2006 revision.

app.activeDocument.stories.everyItem().appliedLanguage=app.languagesWithVendors.itemByID(92)

For a list of languages with id values

var myLans = app.languagesWithVendors;

var myLanNames = [];

for (oneLan=1; oneLan < myLans.length; oneLan++){

    var myLan = myLans[oneLan];

    myLanNames.push(myLan.id+" "+myLan.name);

}

var myText = myLanNames.sort();

myText = myText.join("\n");

alert("Languages\n" + myText)