From c57de8e6fac27657316287116584b11ef0ad8c3e Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Tue, 16 Jun 2026 10:08:51 +0000 Subject: [PATCH] Translate UOM Category (az, ru) + fix extras override Add UOM Category to the translated-doctype pipeline so its values (shown as the `category` column of UOM Conversion Factor) render in az/ru: - force translated_doctype=1 on the DocType JSON (update_doctype.py) - list-view subject formatter (translate_listview_subjects.js + hooks) - 11 missing category names + override of two upstream mistranslations: "Force" (was a verb) and "Area" (was "region") in extras.po (az, ru) Fix _merge_extras: babel's Catalog.__setitem__ only merges metadata for an existing key and never overwrites the translation string, so extras could add new msgids but never correct an existing upstream one. Force the string so "extras wins on conflict" actually holds (this is what made the "Area" override take effect). Co-Authored-By: Claude Opus 4.8 --- az_locale/hooks.py | 1 + az_locale/locale/setup_locale.py | 7 +++ .../locale/translations_az/erpnext/extras.po | 44 +++++++++++++++++++ .../locale/translations_ru/erpnext/extras.po | 44 +++++++++++++++++++ az_locale/locale/update_doctype.py | 4 ++ .../public/js/translate_listview_subjects.js | 1 + 6 files changed, 101 insertions(+) diff --git a/az_locale/hooks.py b/az_locale/hooks.py index 01495b6..1c25b30 100644 --- a/az_locale/hooks.py +++ b/az_locale/hooks.py @@ -62,6 +62,7 @@ doctype_list_js = { "Role": _listview_subject_js, "Role Profile": _listview_subject_js, "UOM": _listview_subject_js, + "UOM Category": _listview_subject_js, "Territory": _listview_subject_js, "Price List": _listview_subject_js, } diff --git a/az_locale/locale/setup_locale.py b/az_locale/locale/setup_locale.py index eac6549..398542a 100644 --- a/az_locale/locale/setup_locale.py +++ b/az_locale/locale/setup_locale.py @@ -117,6 +117,13 @@ def _merge_extras(dest_file, extras_file): except AttributeError: pass dest[msg.id] = msg + # babel's Catalog.__setitem__ only merges metadata for an existing key — + # it does NOT overwrite the translation string. Force it so extras wins + # on conflict (otherwise we can add new msgids but never correct an + # existing upstream translation). + existing = dest.get(msg.id, msg.context) + if existing is not None: + existing.string = msg.string count += 1 try: diff --git a/az_locale/locale/translations_az/erpnext/extras.po b/az_locale/locale/translations_az/erpnext/extras.po index 294b211..ccd28b0 100644 --- a/az_locale/locale/translations_az/erpnext/extras.po +++ b/az_locale/locale/translations_az/erpnext/extras.po @@ -208,3 +208,47 @@ msgstr "Kommunikasiya" # === Territory === msgid "Azerbaijan" msgstr "Azərbaycan" + +#. UOM Category names — DocType fixture data (autoname=field:category_name), +#. shown as the `category` column of UOM Conversion Factor. UOM Category gets +#. translated_doctype=1 forced via az_locale/locale/update_doctype.py. +#. "Force" and "Area" override upstream mistranslations (verb / "region"). +# === UOM Category === +msgid "Mass" +msgstr "Kütlə" + +msgid "Temperature" +msgstr "Temperatur" + +msgid "Magnetic Induction" +msgstr "Maqnit induksiyası" + +msgid "Electric Current" +msgstr "Elektrik cərəyanı" + +msgid "Electrical Charge" +msgstr "Elektrik yükü" + +msgid "Frequency and Wavelength" +msgstr "Tezlik və dalğa uzunluğu" + +msgid "Density" +msgstr "Sıxlıq" + +msgid "Power" +msgstr "Güc" + +msgid "Pressure" +msgstr "Təzyiq" + +msgid "Volume" +msgstr "Həcm" + +msgid "Speed" +msgstr "Sürət" + +msgid "Force" +msgstr "Qüvvə" + +msgid "Area" +msgstr "Sahə" diff --git a/az_locale/locale/translations_ru/erpnext/extras.po b/az_locale/locale/translations_ru/erpnext/extras.po index bfcaa8a..c22e4be 100644 --- a/az_locale/locale/translations_ru/erpnext/extras.po +++ b/az_locale/locale/translations_ru/erpnext/extras.po @@ -208,3 +208,47 @@ msgstr "Коммуникация" # === Territory === msgid "Azerbaijan" msgstr "Азербайджан" + +#. UOM Category names — DocType fixture data (autoname=field:category_name), +#. shown as the `category` column of UOM Conversion Factor. UOM Category gets +#. translated_doctype=1 forced via az_locale/locale/update_doctype.py. +#. "Force" and "Area" override upstream mistranslations (verb / "region"). +# === UOM Category === +msgid "Mass" +msgstr "Масса" + +msgid "Temperature" +msgstr "Температура" + +msgid "Magnetic Induction" +msgstr "Магнитная индукция" + +msgid "Electric Current" +msgstr "Электрический ток" + +msgid "Electrical Charge" +msgstr "Электрический заряд" + +msgid "Frequency and Wavelength" +msgstr "Частота и длина волны" + +msgid "Density" +msgstr "Плотность" + +msgid "Power" +msgstr "Мощность" + +msgid "Pressure" +msgstr "Давление" + +msgid "Volume" +msgstr "Объём" + +msgid "Speed" +msgstr "Скорость" + +msgid "Force" +msgstr "Сила" + +msgid "Area" +msgstr "Площадь" diff --git a/az_locale/locale/update_doctype.py b/az_locale/locale/update_doctype.py index d83e9b6..eab6a3d 100644 --- a/az_locale/locale/update_doctype.py +++ b/az_locale/locale/update_doctype.py @@ -15,6 +15,10 @@ TRANSLATED_DOCTYPES = [ "erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.json", "Supplier Scorecard Variable", ), + ( + "erpnext/stock/doctype/uom_category/uom_category.json", + "UOM Category", + ), ] diff --git a/az_locale/public/js/translate_listview_subjects.js b/az_locale/public/js/translate_listview_subjects.js index 7a0b006..b0f1711 100644 --- a/az_locale/public/js/translate_listview_subjects.js +++ b/az_locale/public/js/translate_listview_subjects.js @@ -18,6 +18,7 @@ const AZ_LOCALE_SUBJECT_FIELDS = { "Role": "name", "Role Profile": "role_profile", UOM: "name", + "UOM Category": "name", Territory: "name", "Price List": "name", };