From c849f0be8b11822b90616ede6e300ef0dfd08143 Mon Sep 17 00:00:00 2001 From: Korbinian Preisler Date: Sat, 26 Sep 2015 15:23:43 +0200 Subject: [PATCH] Allow to import overridden translations from different po-file issue4971 review18581002 --- CHANGELOG | 1 + doc/topics/index.rst | 1 + doc/topics/translation.rst | 64 +++++++++++++++++++++++++++++++++++++ trytond/modules/__init__.py | 6 ++-- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 doc/topics/translation.rst diff --git a/CHANGELOG b/CHANGELOG index 90788b6806..15757cb883 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Load po files also in 'override' subdirectory * Add support for float and integer on Property fields * Remove foreign-key on create_uid and write_uid * Prevent deletion of any user diff --git a/doc/topics/index.rst b/doc/topics/index.rst index 939dacdb3b..c19ba8a467 100644 --- a/doc/topics/index.rst +++ b/doc/topics/index.rst @@ -25,3 +25,4 @@ Introduction to all the key parts of trytond: wizard reports/index modules/index + translation diff --git a/doc/topics/translation.rst b/doc/topics/translation.rst new file mode 100644 index 0000000000..8003e077f7 --- /dev/null +++ b/doc/topics/translation.rst @@ -0,0 +1,64 @@ +.. _topics-translation: + +=========== +Translation +=========== + +The translation of the user interface is provided module-wise. +Translations are stored in the ``locale/`` directory of a module, each language +in a `PO-file `_. The +official language files are named after the +`POSIX locale `_ +standard, e.g. de_DE.po, es_AR.po, es_EC.po... + +The names of custom language files must match the code of the language in the +Model ir.lang. + +If a language is set ``translatable``, the translations will be loaded into +the database on each trytond module update. + + +Translation Wizards +=================== + +Set Report Translations Wizard +------------------------------ + +The wizard adds new translations to the base language ``en_US``. + +Clean Translations Wizard +------------------------- + +The wizard deletes obsolete translations from the database. + +Synchronize Translations Wizard +------------------------------- + +The wizard updates the translations of the selected language based on the +translations of the base language ``en_US``. + +Export Translations Wizard +-------------------------- + +The wizard requires to select a language and a module and will export the +translations for this selection into a PO-file. + + +Override translations +===================== + +Translations of a module can be overridden by another module. This can be done +by putting a PO file into the ``locale/override`` directory of the module that +shall contain the translations to override. + +To override the translation of another module the ``msgctxt`` string must have +the following content: + +type:name:module.xml_id + + * ``type``: Value of the field type of ir.translation. + * ``name``: Value of the field name of ir.translation. + * ``module``: Value of the field module ir.translation. + * ``xml_id``: The XML id that is stored in ir.model.data as fs_id + +The xml_id part is optional and can be omitted if it is None. diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index 66ddda47d2..1a78cea742 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -249,8 +249,10 @@ def load_module_graph(graph, pool, update=None, lang=None): modules_todo.append((module, list(tryton_parser.to_delete))) - for filename in iglob('%s/%s/*.po' - % (package.info['directory'], 'locale')): + localedir = '%s/%s' % (package.info['directory'], 'locale') + for filename in itertools.chain( + iglob('%s/*.po' % localedir), + iglob('%s/override/*.po' % localedir)): filename = filename.replace('/', os.sep) lang2 = os.path.splitext(os.path.basename(filename))[0] if lang2 not in lang: