Page 1 of 1

MenuPick Localization with Menu Line Number

Posted: Sun Jul 13, 2014 5:57 am
by dcpbarrington
Forum,

I need to localize my menus and I'm currently using the standard menuPick

Code: Select all

on menuPick pItemName
   switch pItemName
      case "Settings"
         go to card "Settings"
         break
       case "LogOut"
         logoutRequest
         break
      case "Exit"
         exitRequest
         break
      default
         break 
   end switch
end menuPick
The problem is that the menu text items change depending on the language that is selected.
I want to determine the line number of the menu that was picked instead of the text of the menu.

I know I've seen this somewhere but cannot find it and it is probably quite simple.

Thanks for the help.
dcpbarrington

Re: MenuPick Localization with Menu Line Number

Posted: Sun Jul 13, 2014 6:49 am
by Simon
Hi dcpbarrington,
I was just looking at this myself, here is what I came up with;

Code: Select all

on menuPick pItemName
   repeat with x = 1 to the number of lines in btn 1
      put line x of btn 1 & cr after temp
   end repeat
      put lineOffset(pItemName,temp)
end menuPick
Simon

Re: MenuPick Localization with Menu Line Number

Posted: Sun Jul 13, 2014 11:51 am
by Klaus
Hi folks,

that's what the (not so new) TAGS are made for!
Check "Menu" in the dictionary for more info.

Basicall a menu item is made up like this:
LABEL_what_the_user_sees/accelerator_keyboard_shortcut|TAG_actual_menu

For a copy menu in english and german:
Kopieren/C|copy
Copy/C|copy

Code: Select all

on menupick tItem
switch tItem
case "copy"
  # For ALL languages!
...
The last thing is the TAG and that is always "static", you only need to localize the LABELS!
You get the picture..


Best

Klaus

Re: MenuPick Localization with Menu Line Number

Posted: Mon Jul 14, 2014 1:12 am
by dcpbarrington
Thanks Klaus,

I knew it couldn't be that hard, but couldn't find an explanation in the MenuItem documentation.

So Set the Item Delimitor to "|" and select the second item before starting the Switch Statement.

Should work great.

dcp

Re: MenuPick Localization with Menu Line Number

Posted: Mon Jul 14, 2014 12:19 pm
by Klaus
dcpbarrington wrote:So Set the Item Delimitor to "|" and select the second item before starting the Switch Statement.
No need to set or select anything for the "menupick" handler, if that is what you mean!
See my example!