Files
odoo_source/addons/transifex/models/models.py
T
Chong Wang (cwg) 6346f52acf [ADD] transifex: add transifex module to help translation
model/model_terms translations:
A transifex link if available is displayed after the language in the translation
dialog to help translators to contribute their translations. The tooltip message
for mouse hovering is 'Contribute'

code translations:
Setting -> Translations -> Application Terms -> Transifex Code Translations

In order to reuse the list view and search bar, model transifex.code.translation
is created to store all code translations.
This model is
1. readonly
2. reloaded on demand/by cron(7 days) to avoid increasing the Odoo restart time
3. updated for new installed modules/languages while opening the list view
4. shared to all users without duplicated translations

closes odoo/odoo#111685

X-original-commit: 7b30badb52e2a948c41f4340a01f6118818c6711
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Wang Chong (cwg) <cwg@odoo.com>
2023-02-03 06:05:51 +01:00

32 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class BaseModel(models.AbstractModel):
_inherit = 'base'
def get_field_translations(self, field_name, langs=None):
""" get model/model_term translations for records with transifex url
:param str field_name: field name
:param list langs: languages
:return: (translations, context) where
translations: list of dicts like [{"lang": lang, "source": source_term, "value": value_term,
"module": module, "transifexURL": transifex_url}]
context: {"translation_type": "text"/"char", "translation_show_source": True/False}
"""
translations, context = super().get_field_translations(field_name, langs=langs)
external_id = self.get_external_id().get(self.id)
if not external_id:
return translations, context
module = external_id.split('.')[0]
if module not in self.pool._init_modules:
return translations, context
for translation in translations:
translation['module'] = module
self.env['transifex.translation']._update_transifex_url(translations)
return translations, context