Changes between Version 4 and Version 5 of DeveloperGuidelines/Internationalisation


Ignore:
Timestamp:
07/29/09 01:39:29 (12 years ago)
Author:
Fran Boon
Comment:

Pattern uses reusable field

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Internationalisation

    v4 v5  
    1212To make dropdown options localisable, use this pattern:
    1313{{{
     14module_table_field_opts = {
     15    1:T('Option1'),
     16    2:T('Option2'),
     17    3:T('Option3')
     18    }
     19opt_module_field = SQLTable(None, 'module_table_field',
     20                    db.Field('module_table_field', 'integer',
     21                    requires = IS_IN_SET(module_table_field_opts),
     22                    default = 1,
     23                    represent = lambda opt: opt and module_table_field_opts[opt]))
     24
    1425db.define_table(table,
    15                 Field('category_type', 'integer', notnull=True),
    16                 ...
    17                 )
    18 table_field_opts = {1:T('Option1'), 2:T('Option2')}
    19 db[table][field].requires = IS_IN_SET(table_field_opts)
    20 db[table][field].represent = lambda opt: table_field_opts[opt]
     26               opt_module_field,
     27               ...
     28               )
    2129}}}
    2230