Interesting.
If it would be an interest for you, there is a small gettext compatible library 
(that means you can use gettext tools to extract strings from your code, use
poedit to make translations etc) - and it is only about 200 lines of code!

  http://number-none.com/blow/code/mo_file/index.html

It is very small, fluid-compatible and does wonders for me with some changes 
and additional "macro magic" to get possibility to do different unique 
translations
at different places even for the same original English strings. Granted this 
would normally be only static translations - that means restarting application /
reloading strings is needed after language change but...

But therere is another possibility for "dynamic result" - which I have not 
tested yet:
Replace *draw* and *measure* functions for normal labeltype (that is 
enumeration 0, maybe other used too) with something like

  void my_label_draw(const char *s, ...){ original_label_draw(_(s), ...);}
  void my_label_measure(const char * s, ...){ original_measure(_(s), ...);}

and use

  Fl::set_labeltype(FL_NORMAL_LABEL, &my_label_draw, &my_label_measure);

at the beginning of the program. This would allow global dynamic language 
swapping without any changes to your application and without any need to
restart/reload strings but might be little bit dangerous and break things at 
places. Alternatively you could define your own labeltype above the defaults
and set this labeltype only to menus and widgets you want to be translated.

R.



On 28/11/2011 19:41, Greg Ercolano wrote:
> I was recently asked about how to make an application multilingual.
> ie. how to have the app's menubar show up in a different language,
> and have this be changeable from the menubar.
> 
> Here's an example that shows a common technique, which involves
> assigning each menu item an 'internal name' the app uses internally
> for searching and internal bookkeeping, separate from the menu item's
> label() names, which can change depending on the currently selected
> language.
> 
> The technique used is to make a simple little class ("ItemData)
> is used as the userdata() for each menu item, to allow more data
> to be associated with each item than just the 'this' of the app;
> it keeps track of the 'internal menu name' as well.
> 
> I've added this example to my FLTK cheat sheet here:
> http://seriss.com/people/erco/fltk/#MultiLanguageApp
> 

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to