Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[IMP] *: translation methods cleaning #38859
Extract some cleaning wanted in #30759 but not related to language packs
Only activated languages should be used in "amount to text" features. If a language code of a not-used language is used, it should be ignored for consistency with the rest of the interface.
load_lang was a kind of hybrid method trying to active or creating a language if not found. This was error prone. Instead rely on two methods with clear purpose: ResLang._create_lang(lang, lang_name=None) - create a new res.lang entry using the locale of the server return the res.lang record to match the API of _activate_lang ResLang._active_lang(code) - activate the given code lang Most of the time, _active_lang is what is expected tools.trans_load_data and IrTranslation._load_module_terms no longer activate the language if not active. Loading the translations should be explicit on an activated language, it is too error prone to silently activate/create a language if not found. Remove lang_name from trans_load_data as no longer needed.
Instead of relying on the context content, pass explicit values for overwrite and create_empty_translations applu this to trans_load and trans_load_data Adapt the test that was relying on empty translations.
Instead, updating the translations of a module should be done directly on the ir.module.module record
It was misleading as only forced for translations of type 'code' but for the other translations, it was retrieved from the imported file (the comment in a .po file or column in a .csv)
Instead of previous long methods, use a class to clarify what the export actually does. Remove the 'all_installed' possibility in modules as it was not working (creating query with 2 WHERE clause). Simplify writer by deducing modules from exported translations