Howto:Processing legacy PUI dialogs using Canvas: Difference between revisions

Jump to navigation Jump to search
Line 1,385: Line 1,385:
=== Supporting Translations ===
=== Supporting Translations ===
{{Stub}}
{{Stub}}
Our existing GUI is fairly simple, but it all goes through XML and the/a property tree, which is an advantage here.This was previously discussed on the issue tracker a while ago:
So with some work, anything that uses PropertyList/XML can still be localied by using "post-processing hooks", i.e. you first load the actual file (e.g. about.xml) and then load a localized version of the same file (with just the strings replaced) into the same props.Node/SGPropertyNode. Given James' work on Nasal-based fgcommands, we can trivially overwrite fgcommands like '''show-dialog''' with our own implementation (wrapping the original fgcommand, or using a custom '''show-localized-dialog''') that basically:
*  load a GUI dialog like about.xml
*  check if there is a matching XML file in $FG_ROOT/Translations/it/gui/dialogs/about.xml
*  if so, load it into the same tree, basically replacing those original English strings
Et voila, you'll end up with a very simple localization method without having to edit any C++ code
Alternatively, we could use the include/params construct to overwrite/replace default strings with stuff from $FG_ROOT/Translations
I don't even think that it requires much in terms of Nasal, it's probably under 100 lines of code to do it this way.<ref>{{cite web
  |url    =  https://forum.flightgear.org/viewtopic.php?p=207989#p207989
  |title  =  <nowiki> Re: Total translation of the simulator in Italian </nowiki>
  |author =  <nowiki> Hooray </nowiki>
  |date  =  May 3rd, 2014
  |added  =  May 3rd, 2014
  |script_version = 0.40
  }}</ref>
$FG_ROOT/Translations contains references that are looked up by the menubar - so the menubar merely contains property references, not the strings - the translated strings are then looked up using those properties - e.g. see $FG_ROOT/Translations/en/menu.xml (?)
$FG_ROOT/Translations contains references that are looked up by the menubar - so the menubar merely contains property references, not the strings - the translated strings are then looked up using those properties - e.g. see $FG_ROOT/Translations/en/menu.xml (?)
Next, check preferences.xml for the &lt;intl&gt; tag that includes Translations/locale.xml
Next, check preferences.xml for the &lt;intl&gt; tag that includes Translations/locale.xml

Navigation menu