Changes between Version 4 and Version 5 of DeveloperGuidelines/Internationalisation
- Timestamp:
- 07/29/09 01:39:29 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Internationalisation
v4 v5 12 12 To make dropdown options localisable, use this pattern: 13 13 {{{ 14 module_table_field_opts = { 15 1:T('Option1'), 16 2:T('Option2'), 17 3:T('Option3') 18 } 19 opt_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 14 25 db.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 ) 21 29 }}} 22 30