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
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
...
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);
Copy link to clipboard
Copied
ECMA 3. So most modern JS global functions are not available.
Copy link to clipboard
Copied
Hereās the API
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#$.html
And here is the InDesign API
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html
Copy link to clipboard
Copied
And here are the basic Extendscript docs. Code like it's 1999!
- Mark
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
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);
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
-Manan
Copy link to clipboard
Copied
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