camiloGS
(Camilo Gonzalez)
November 30, 2024, 10:53pm
1
Hi, I’m trying to create translations for record names from code.
This is the behavior I’m trying to automate (using products.products as example)
This is how it’s being saved in ir.translation:
Doing it in this way it works as expected (When I change the user preferences to spanish I see the translation in the product name)
I’m trying to create the ir.translation record in an xml file, like this:
<record model="ir.translation" id="product_template_computer_translation">
<field name="lang">es</field>
<field name="src">Computer</field>
<field name="name">product.template,name</field>
<field name="value">Tekomputer</field>
<field name="type">model</field>
</record>
Debbuging the process I noticed that the ir.translation record is being deleted after the module activation/upgrade
Thank’s in advance!
ced
(Cédric Krier)
November 30, 2024, 10:57pm
2
The translations are created using po-file
.
You can use the translation wizards to generate the po file of a module.
Or you can use the --export-translations
options of trytond-admin
(if you are using series >= 7.4).
camiloGS
(Camilo Gonzalez)
December 1, 2024, 3:10pm
3
Thank’s for the answer. I understand that .po files are used to translate fields, like this:
msgctxt "field:product.product,name:"
msgid "Name"
msgstr "Nombre"
But how would I translate the name of the record of the product itself?
For example, I extended the product module and added some products using xml, like this
<record model="product.template" id="my_custom_product">
<field name="name">My custom product</field>
...
</record>
How would I create the translation for the record so in the view the product is showed as for example “Mi producto personalizado” instead of “My custom product”?
ced
(Cédric Krier)
December 1, 2024, 3:37pm
4
If you create records with XML (not advised for operational data), they will be included in the PO file export of the module.
PS: it is really not recommended to create product via XML because they will be read only.