Skip to main content
Bedazzled532
Inspiring
June 21, 2024
Answered

Single Liner script for Language

  • June 21, 2024
  • 3 replies
  • 584 views

Hi,

 

I am looking for a single liner script to find the applied language in a document.

I am tring this:

app.activeDocument.pages.item(0).textFrames.item(0).parentStory='Farsi'

 

For some reason this script is not working and it is not giving any error also.

 

Actually its part of a script where I have to specify the option for find and replace a text only if it is in a specifig language. So I have to use this snippet of single liner as an argument in that script.

 

Link to the script

http://kasyan.ho.ua/indesign/2019/find_replace/find_replace.html

This topic has been closed for replies.
Correct answer Bedazzled532

Ok I found it.

 

Here is the single liner script:
appliedLanguage:app.languagesWithVendors.itemByID(119)   // 119 denotes Farsi

3 replies

Community Expert
June 22, 2024

Hi @Bedazzled532,

As @rob day explained in detail that the document can have possibly many languages applied to the text so your one liner would not be a complete solution. The code should be just a simple addition to check for the language as well with the find/change grep or find/change text.

-Manan

-Manan
rob day
Community Expert
Community Expert
June 21, 2024

I am looking for a single liner script to find the applied language in a document.

 

Hi @Bedazzled532 , In case it isn’t clear Language is a character level property—a document could have texts set in multiple languages. Your one liner gets a language with the ID 119 if it is installed, but the active document may or may not use that language—this doc has both English and French text:

 

Bedazzled532
Inspiring
June 22, 2024

@rob day @Manan Joshi Thanks for the input. Actually I needed this one liner for inclusion in an existing script as an argument. I have shared the link of the script in above post. I have also shared a single liner which I came up with and it is working.

Thanks

Bedazzled532
Bedazzled532AuthorCorrect answer
Inspiring
June 21, 2024

Ok I found it.

 

Here is the single liner script:
appliedLanguage:app.languagesWithVendors.itemByID(119)   // 119 denotes Farsi

Legend
June 22, 2024

Be prepared that the ID is not always stable.

It may differ with a different version of InDesign, or with plug-ins added or removed, or …

 

rob day
Community Expert
Community Expert
June 22, 2024

Right, this returns false with my InDesign install:

 

$.writeln(app.languagesWithVendors.itemByID(119).isValid)
//returns false