• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Change doubleQuotes using javascript

New Here ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

Good Morning and Happy new Year.

I'm trying to change the preference of double quotes with javascript, my code is:

 

var languages= activeDoc.languages;
if (languages != null) {
  var language= languages[0];
  language.doubleQuotes = '””'
}

but this code don't run.

Does anyone know how to change this preference?

thank you

TOPICS
Scripting , SDK

Views

75

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
Community Expert ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

 Can't you use Find/Change, once for opening and once for closing quotation marks?

Screenshot 2023-01-04 at 10.20.30.png

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
Community Expert ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

LATEST

Hi @israelp20923262, since you are doing scripting, have a look at this snippet:

function main() {

    // select some text, then run script

    var doc = app.activeDocument,
        text = doc.selection[0];

    if (!text.hasOwnProperty('appliedLanguage')) {
        alert('Please select some text and try again.');
        return;
    }

    var lang = doc.languages.itemByName(text.appliedLanguage.name);

    lang.doubleQuotes = "””";

}


app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Set Language Quotes');

 

I think the key point is how you target the correct language. activeDoc.languages[0] usually means "No Language", so that might be the problem in your case. To make it streamlined, I am just using the selected text to tell us which language is applied, and change the double quotes for that language.

- Mark

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