Skip to main content
Legend
February 3, 2017
Answered

invoking menu - language

  • February 3, 2017
  • 3 replies
  • 7116 views

Hello,

Does invoking a menu with the menu string work in any language? Example.

$ID/Override All Master Page Items

P.

This topic has been closed for replies.
Correct answer Laubender

I should have added:


It should work as long as you provide the locale-independent form of the string.

Sometimes simply adding $ID/ in front of the English menu name does not work or is not enough.
Better look for the title string of a menu and check with:

app.findKeyStrings("menu-title-name");

for the "universal" form(s) of the string.

Regards,
Uwe

3 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
February 3, 2017

I should have added:


It should work as long as you provide the locale-independent form of the string.

Sometimes simply adding $ID/ in front of the English menu name does not work or is not enough.
Better look for the title string of a menu and check with:

app.findKeyStrings("menu-title-name");

for the "universal" form(s) of the string.

Regards,
Uwe

robinfredericf
Participating Frequently
June 8, 2017

Hi, I have some trouble trying to use universal menu strings:

Some confrere submitted me a script idea, showing me a manual trick that he had designed to selectively get rid of specific unwanted style replacements in paragraphs while preserving other replacements:
http://robinfredericf.free.fr/misc/wadym-s_Idea.avi.mp4
http://robinfredericf.free.fr/misc/wadym-s_idea.png

I was interested in automating it in a script but his method uses the command "Redefine style" that doesn't exists in the InDesigns ExtendScript API, so I tried to «invoke()» it, following explanations that I read on adobe forum topics such as
https://forums.adobe.com/thread/1961958
http://kasyan.ho.com.ua/open_menu_item.html
https://forums.adobe.com/thread/892886

To get the required command to redefine a paragraph style from the selection, in a international reliable way, I decided at once to avoid to get the menuAction by its id or index because it seemed hazardous, those numbers could be assigned to totally different actions in different InDesign version, so i tried:

var redefineParagraphStyle = app.menus.item('$ID/ParaStylePanelPopup').menuItems.item('$ID/Redefine Style'); 
redefineParagraphStyle.associatedMenuAction.invoke();

[including jsx and demo idml file:]
http://robinfredericf.free.fr/misc/wadyms-paragraphstyle-trick_indd002.zip
http://robinfredericf.free.fr/misc/wadyms-paragraphstyle-trick_indd002-en.zip

I expected that the use of "$ID/" english strings would prevent the localization problems but unfortunately I was surprised when my colleague told me that he got the error «ReferenceError: Object is invalid»

So then I tried:

var redefineParagraphStyle = app.menus.item('$ID/ParaStylePanelPopup').menuItems.item('$ID/RedefineStyle'); 
var redefineParagraphStyle = app.menus.item('$ID/ParaStylePanelPopup').menuItems.itemByID(8458);
var redefineParagraphStyle = app.menus[113].menuItems[3];

http://robinfredericf.free.fr/misc/wadyms-paragraphstyle-trick_indd002a.zip

All methods worked on my side, tested on French localized versions of InDesign CS5 & CC 2015.4 under MacOSX 10.10.5 & Windows 7

But still the same "Object is invalid" error on my Ukrainian colleague's side, who tested the scripts on Russian localized versions of CS5.5 &  CC 2015.2 (11.2.0.100х64) under Windows 7.

TᴀW
Legend
June 8, 2017

I haven't tested anything, but IIRC some menu items are only valid when the relevant panel is open. So if the paragraph styles panel is closed on your friend's computer, he may get an error.

Ariel

Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.
tpk1982
Legend
February 3, 2017

I hope you asking the menu action work in all scripting language?

Community Expert
February 3, 2017

Hi Pickory,

it should, if the menu is available in the situation you want to use it.
E.g "Override All Master Page Items" is not available if no document is open.

See for example:

var menuAction = app.menuActions.itemByName("$ID/Override All Master Page Items");

for(x in menuAction)

{

    $.writeln(x+"\t"+menuAction);

  

};

// CASE 1 No document open with my German InDesign

/*

  

  

    name    Alle Musterseitenobjekte übergehen

    title    Alle Musterseitenobjekte übergehen

    area    Bedienfeldmenüs:Seiten

  

    enabled    false

  

    checked    false

    id    6164

    label  

    isValid    true

    parent    [object Application]

    index    101

    properties    [object Object]

    events    [object Events]

    eventListeners    [object EventListeners]

    isValid    true

  

*/

// CASE 2 Document open with my German InDesign.

/*

  

    name    Alle Musterseitenobjekte übergehen

    title    Alle Musterseitenobjekte übergehen

    area    Bedienfeldmenüs:Seiten

  

    enabled    true

  

    checked    false

    id    6164

    label  

    isValid    true

    parent    [object Application]

    index    101

    properties    [object Object]

    events    [object Events]

    eventListeners    [object EventListeners]

    isValid    true

  

*/

So before using it you could look after the value of property enabled.

Maybe also isValid if you are not sure if a specific InDesign version does provide the menu.

var menuAction = app.menuActions.itemByName("$ID/Override All Master Page Items");

if(menuAction.enabled){menuAction.invoke()};

( Just for lurkers: InDesign Server does not support menuActions )

Regards,
Uwe