details: https://code.tryton.org/tryton/commit/c9e7bd3f3928
branch: default
user: Nicolas Évrard <[email protected]>
date: Fri Oct 24 10:22:38 2025 +0200
description:
Do not allow translations to be set or exported unless the default
language is English
diffstat:
trytond/doc/topics/translation.rst | 4 ++--
trytond/trytond/ir/message.xml | 7 ++++++-
trytond/trytond/ir/translation.py | 15 +++++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
diffs (70 lines):
diff -r c95c653458c9 -r c9e7bd3f3928 trytond/doc/topics/translation.rst
--- a/trytond/doc/topics/translation.rst Tue Oct 21 18:24:52 2025 +0200
+++ b/trytond/doc/topics/translation.rst Fri Oct 24 10:22:38 2025 +0200
@@ -38,8 +38,8 @@
------------------------
The wizard updates the translations of the selected language based on the
-translations of the base language ``en``. It will also remove duplicate
-translations with its direct parent.
+translations of the :ref:`database language <config-database.language>`.
+It will also remove duplicate translations with its direct parent.
Export Translations
-------------------
diff -r c95c653458c9 -r c9e7bd3f3928 trytond/trytond/ir/message.xml
--- a/trytond/trytond/ir/message.xml Tue Oct 21 18:24:52 2025 +0200
+++ b/trytond/trytond/ir/message.xml Fri Oct 24 10:22:38 2025 +0200
@@ -343,7 +343,12 @@
<record model="ir.message" id="msg_translation_overridden">
<field name="text">You can not export translation "%(name)s"
because it has been overridden by module "%(overriding_module)s".</field>
</record>
-
+ <record model="ir.message" id="msg_translation_set_default_lang">
+ <field name="text">To set translations, the default language must
be "English".</field>
+ </record>
+ <record model="ir.message" id="msg_translation_export_default_lang">
+ <field name="text">To export translations, the default language
must be "English".</field>
+ </record>
<record model="ir.message" id="msg_module_delete_state">
<field name="text">You can not remove a module that is activated
or that is about to be activated.</field>
diff -r c95c653458c9 -r c9e7bd3f3928 trytond/trytond/ir/translation.py
--- a/trytond/trytond/ir/translation.py Tue Oct 21 18:24:52 2025 +0200
+++ b/trytond/trytond/ir/translation.py Fri Oct 24 10:22:38 2025 +0200
@@ -49,6 +49,10 @@
pass
+class DefaultLanguageError(UserError):
+ pass
+
+
class TrytonPOFile(polib.POFile):
def sort(self):
@@ -1267,6 +1271,12 @@
& ~translation.src.in_(strings)))
def transition_set_(self):
+ pool = Pool()
+ Config = pool.get('ir.configuration')
+ default_lang = Config.get_language()
+ if default_lang != INTERNAL_LANG:
+ raise DefaultLanguageError(gettext(
+ 'ir.msg_translation_set_default_lang'))
self.set_report()
self.set_view()
return 'succeed'
@@ -1733,6 +1743,11 @@
def transition_export(self):
pool = Pool()
Translation = pool.get('ir.translation')
+ Config = pool.get('ir.configuration')
+ default_lang = Config.get_language()
+ if default_lang != INTERNAL_LANG:
+ raise DefaultLanguageError(gettext(
+ 'ir.msg_translation_export_default_lang'))
self.result.file = Translation.translation_export(
self.start.language.code, self.start.module.name)
return 'result'