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

ExtendScript

New Here ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

howdy,

what version of javascript is used by extendscript?

wonder if variable resolution in string literals is support, e.g.

var _name = 'Dude'; alert(`howdy ${_name}`);

cheers,

PJ

TOPICS
Scripting

Views

434

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 2 Correct answers

Community Expert , Jul 16, 2022 Jul 16, 2022

Hi @Patrick Jaeger,

As has already been pointed out by other participants of the discussion, Extendscript is based on a very old standard so such mordern features are not available to it. However for your particular example we have a method that works almost like it. The method is localize, see the documentation at the following link

 https://www.indesignjs.de/extendscriptAPI/indesign-latest/#global.html#d1e3846__d1e4325

So your code sample could be rewritten as following

var _name = 'Dude'; ale
...

Votes

Translate

Translate
Community Expert , Jul 18, 2022 Jul 18, 2022

Well, Patrick didn't say he was interested in localisation, all he wanted was to use a variable in s string. Seems to me that all he needs is

var _name = 'Dude'; alert('howdy ' + _name);

Votes

Translate

Translate
Community Expert ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

ECMA 3. So most modern JS global functions are not available. 

Votes

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Votes

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

And here are the basic Extendscript docs. Code like it's 1999!

- Mark

Votes

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 ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

Hi @Patrick Jaeger,

As has already been pointed out by other participants of the discussion, Extendscript is based on a very old standard so such mordern features are not available to it. However for your particular example we have a method that works almost like it. The method is localize, see the documentation at the following link

 https://www.indesignjs.de/extendscriptAPI/indesign-latest/#global.html#d1e3846__d1e4325

So your code sample could be rewritten as following

var _name = 'Dude'; alert(localize("howdy %1", _name));

-Manan

Votes

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 ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Well, Patrick didn't say he was interested in localisation, all he wanted was to use a variable in s string. Seems to me that all he needs is

var _name = 'Dude'; alert('howdy ' + _name);

Votes

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 ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

Hi @Peter Kahrel,

Frankly speaking I have never used the localise method for localisation nor do I have any idea how that would work(would be great if you could share some examples for it). The reason I suggested this method was due to its capability to mimic the template literals of modern JS, specifically it's string interpolation functionality. String interpolation of all things make long strings intersperesed with results of expressions a lot easier to read. As far as I understood that is what the OP is after, even though the example used was a simplistic one and hence my suggestion. See the following

String interpolation

-Manan

Votes

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 ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

LATEST

Hi @Manan Joshi -- Fair enough: string interpolation does make such strings easier to read., especially for those in the example in the link you provided. But using localize doesn't do much for readability I don't think.

 

In ExtendScript localisation is typically used to localise strings linguistically for user interfaces, as outlined in the "JavaScript Tools Guide CC", accessed in th ESTK's Help menu.

 

Peter

Votes

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