5 Replies Latest reply on Dec 14, 2011 3:35 AM by Harbs.

    appliedLanguage > List of available languages

    Stefan Bogner

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




      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,




      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++){



      var myText = myLanNames.sort();

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

      // Bildschirmausgabe

      alert("Languages\n" + myText)

      // Dateiausgabe



      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 );  




      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.

        • 1. Re: appliedLanguage > List of available languages
          Haakenlid Level 3

          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.




          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)
          1 person found this helpful
          • 2. Re: appliedLanguage > List of available languages
            Marc Autret Level 4

            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[i] = a[i] + " => " + app.findKeyStrings(a[i]).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]




            • 4. Re: appliedLanguage > List of available languages
              Stefan Bogner Level 1

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

              • 5. Re: appliedLanguage > List of available languages
                Harbs. Level 6

                Very nice, Marc.