Translation module

From MapbenderWiki

Jump to: navigation, search

The trivial way: load a GUI in a specific language

a GET parameter LANG is passed to login.php, for example

http://localhost/mapbender/frames/login.php?name=test&password=test&lang=en&mb_user_myGui=gui

the easy way: application reload required

allows selection of the locale, sets the session variable and reloads the application

  • available languages passed via element vars in comma separated list
  • selectbox with language options, current language pre-selected
  • onchange an AJAX is fired, changing a session variable $_SESSION["mb_lang"]
  • the gui is reloaded
  • the locale is set according to the $_SESSION variable
  • see module mod_switchLocale.php, mod_setLocale.php
  • backwards compatible

the sophisticated way: no reload required

allows selection of a locale, sets the session variable and calls the l10n functions in map.js

like module switchLocale with the following changes

  • (the locale is stored in JS)
  • new array mb_registerL10nFunctions
  • each module has a function modulename_localize(), which is registered at mb_registerL10nFunctions
    • the localize routine fires an AJAX request which gets the strings in the new locale
    • see module digitize
  • after the locale is set, the registered functions are evaluated
  • there is no reload
  • not backwards compatible

to do:

  • add a localization function to each module (problems with buttons, as they don't have a real init function)
  • isolate strings in JS, move to PHP file (where l10n occurs, via gettext or db-gettext)
Personal tools