Menubar on Windows???

Richard Gaskin ambassador at fourthworld.com
Fri Dec 14 13:48:52 EST 2007


Ron wrote:
> In my case, there are 2 or 3 menubars on each window. However, each  
> is for a different language so only one is displayed at a time,  
> depending on the user's language setting.

You may find it simpler to just have one menu bar and store the menu 
items in a custom property set, with a different property for each language.

To display the appropriate list for the current language, use something 
like this in your menubar group:

on mouseDown
    global gCurLang -- contains the name of the current language
    --
    repeat with i = 1 to the number of menus
      put the uMenuItems[gCurLang] of menu i into menu i
    end repeat
end mouseDown

To get the appropriate labels for the menus themselves, you could have 
something like this in a preOpenStack handler:

on preOpenStack
    global gCurLang -- contains the name of the current language
    --
    repeat with i = 1 to the number of menus
      set the label of menu i to the uMenuNames[gCurLang] of menu i
    end repeat
end preOpenStack

This way you only have to maintain one set of menus, keeping your code 
in one place and making it easy to modify at any time.

I have one project currently which does on-the-fly translation for two 
languages like this.

Down the road I have another app which will need to support multiple 
languages, and we'll take this method one step further by having a 
separate stack file for each language filled with properties which are 
the labels and contents for menus and controls, the keys for those 
properties being object descriptors.  This way we can add new languages 
at any time by just adding another stack, with a tool worms through the 
UI to create the empty properties to be filled in, and a convenient UI 
for the translater to work with as they go through the program.

You might be surprised how fast it can be change the labels and contents 
of controls on the fly.  On preOpenStack, before it's rendered, it's 
pretty darn fast, barely noticeable.

-- 
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list