wiki:DeveloperGuidelines/Internationalisation

Version 13 (modified by Fran Boon, 14 years ago) ( diff )

--

Internationalisation

The original language of the Sahana Eden user interface, source code labels and comments, and the Wiki pages is English (international). No contributions can be accepted without being at least translated to english. If you need help to translate your contents to english, please contact the Sahana Localization team.

However, translation to other languages is highly appreciated - please contact the Localization team for advice.

Web2py localization engine

  • Tutorial: http://www.vimeo.com/7520812
  • T() function performs dictionary lookups (similar to GNU/gettext _()), see here for example
    • Convenience function: Use Tstr() for non web2py python modules that aren't aware of T()
  • the dictionaries are located in the languages subfolder of the application
  • dictionaries can be translated using the web2py web interface (RAD mode)
    • suggest increasing the timeout from the default 10 minutes: python web2py.py --timeout=120 ...

All Labels should be explicitly Internationalised:

db.table.field.label = T('Field')

To make dropdown options localisable, use this pattern:

module_field_type_opts = {
    1:T('Option1'),
    2:T('Option2'),
    3:T('Option3')
    }
opt_module_field_type = SQLTable(None, 'opt_module_field_type',
                    db.Field('field_type', 'integer', notnull=True,
                    requires = IS_IN_SET(module_field_type_opts),
                    default = 1,
                    represent = lambda opt: opt and module_field_type_opts[opt]))

db.define_table(table,
               opt_module_field_type,
               ...
               )

All reference to the options in View code should be by Index not by string (since the string can be changed).

Time

All references to time should use request.utcnow rather than request.now

Pootle/translate toolkit and web2py dictionaries

Wiki pages translation

  • translated pages with ISO 639-2 language code extension (original english page = no extension), e.g.
    • original page: trac.sahanapy.org/wiki/BluePrintInternationalisation
    • german translation: trac.sahanapy.org/wiki/BluePrintInternationalisation/de
  • insert [[TranslatedPages]] macro to display a list of available translations of a page (at best at bottom of page)

BluePrintInternationalisation

DeveloperGuidelines

Note: See TracWiki for help on using the wiki.