USERS

Users are defined by the model `*res.user* <http://hg.tryton.org/trytond/file/3.2/trytond/res/user.py#l42>`_.

A user may have a language set on the field *language*.
The value of the field *language* is the *id* of a language of the model *ir.lang*

After the login you should request the user context from the server.
It contains informations about the language and the locales to use for this user.
Use the method `*res.user.get_preferences* <http://hg.tryton.org/trytond/file/3.2/trytond/res/user.py#l365>`_ to request this informations from the server.

Example of request params::

{
"id": 2,
"method":"model.res.user.get_preferences",
"params":[userid, sessionid, True, {}]
}

This will return a dictionary that you should always use as the last param of a request.
This way the server knows which language setting to use.

Example of a complete context returned by *res.user.get_preferences()*::

{

u'language': u'de_DE',
u'employee.rec_name': u'Korbinian Preisler',
u'locale': {

u'date': u'%d.%m.%Y',
u'thousands_sep': u"'",
u'grouping': [3, 3, 0],
u'decimal_point': u'.'

},

u'language_direction': u'ltr',
u'company_work_time': {

u'Y': 999999999, u'M': 99999999, u'd': 999999, u'w': 9999999

},
u'company.rec_name': u'virtual things',
u'groups': [8, 9, 16, 21, 2, 14, 4, 3, 20, 12, 13, 22, 19],
u'employee': 1,
u'company': 1

}

LANGUAGES

Languages are defined by the model `*ir.lang* <http://hg.tryton.org/trytond/file/3.2/trytond/ir/lang.py#l23>`_.

Every language has a code.
This code should be used to reference languages.
Only the languages that have the fields *translatable* and *active* set to *True* should be used.

Example of request params::

{

"id": 1,
"method":"model.ir.lang.search_read",
"params":[

userid,
sessionid,
[('active', '=', True), ('translatable', '=', True)],
0,
None,
[('name', 'ASC')],
['id', 'name', 'code', 'translatable', 'active'],
{language': 'de_DE'} # Replace this with a complete context

]

}

If you replace the empty dictionary {} at the end of the request params by the context you will receive the language names in the language that is set on the user.

 

TRANSLATED FIELD NAMES

All fields are defined on the model `*ir.model.field* <http://hg.tryton.org/trytond/file/3.2/trytond/ir/model.py#l203>`_.

If you want to retrieve the translated field names for the model *party.party* lets say german language, you can use these request params::

{
"id": 2,
"method":"model.ir.model.field.search_read",
"params":[

userid,
sessionid,
[('model.model', '=', 'party.party')],
0,
None,
[('name', 'ASC')],
['id', 'name', 'model', 'field_description'],
{language': 'de_DE'} # Replace this with a complete context

]
}

CONTENT OF TRANSLATABLE FIELDS

As long as you add the context to your request params you will receive the values of translated fields depending on the language that is set in this context.