Hi @HEAJHP, I can confirm that there is definitely a bug with the app.LanguagesWithVendors.itemByName method: it does not return a valid language when you ask for "Dutch: 2005 Reform".
Fortunately it is simple to work around—loop through all the languages and you will find one named "Dutch: 2005 Reform".
Here is example code:
/**
* @file Make Dutch Style.js
*
* Duplicates the source style and applies Dutch language to it.
*
* @author m1b
* @version 2025-09-05
* @discussion https://community.adobe.com/t5/indesign-discussions/javascript-amp-colon-appliedlanguage-error-with-dutch-spelling-reform-id-96-in-indesign/m-p/15489771
*/
function main() {
var sourceParagraphStyleName = 'journal_actu_item_1_FR';
var targetLanguageUntranslatedName = 'nl_NL_2005';
var targetLanguageCode = 'NL';
var doc = app.activeDocument;
var sourceStyle = getThing(doc.allParagraphStyles, 'name', sourceParagraphStyleName);
if (!sourceStyle)
return alert('Paragraph style "' + sourceParagraphStyleName + '" is not valid.');
var targetLanguage = getThing(app.languagesWithVendors, 'untranslatedName', targetLanguageUntranslatedName);
if (!targetLanguage)
return alert('Language "' + targetLanguageUntranslatedName + '" is not valid.');
var matchTrailingCountryCode = /_[A-Z]{2}$/;
var destinationStyle = sourceStyle.duplicate();
var newName = matchTrailingCountryCode.test(sourceStyle.name)
? sourceStyle.name.replace(matchTrailingCountryCode, '_' + targetLanguageCode)
: sourceStyle.name + '_' + targetLanguageCode;
destinationStyle.properties = {
name: newName,
appliedLanguage: targetLanguage,
};
}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Make Dutch Style');
/**
* Returns a thing with matching property.
* If `key` is undefined, evaluate the object itself.
* @author m1b
* @version 2024-04-21
* @param {Array|Collection} things - the things to look through.
* @param {String} [key] - the property name (default: undefined).
* @param {*} value - the value to match.
* @returns {*?} - the thing, if found.
*/
function getThing(things, key, value) {
for (var i = 0; i < things.length; i++)
if ((undefined == key ? things[i] : things[i][key]) == value)
return things[i];
};
Edit 2025-09-05: for getting the language, I changed the lookup property from "name" to "untranslatedName" in accordance with the great information supplied by @Laubender. I hope this will work on any language version of Indesign.
P.S. anyone looking for the "untranslatedName" of a particular language? Run this code to get a list:
(function () {
var everyLanguage = app.languagesWithVendors.everyItem();
var names = everyLanguage.name;
var untranslatedNames = everyLanguage.untranslatedName;
var printout = 'Language Name / Untranslated';
for (var i = 1; i < names.length; i++)
printout += '\n' + names[i] + ' / ' + untranslatedNames[i];
alert (printout);
})();