blender/scripts/modules/bl_i18n_utils
Damien Picard 446a653cb7 I18n: improve add-on translation tooling
- Allow versions from bl_info to be strings
  Versions are now allowed to be strings in extensions using
  blender_manifest.toml, so this commit prevents them from being badly
  formatted on extraction to add-on translations.

- Do not export Blender copyright text to add-on translations
  This text is only relevant for Blender and maybe core add-ons, not
  for the general case.

- Copy comment lines from add-on .po files to .py translations
  Without this comments added by translators could be lost since they
  were not copied over to the Python files.

- Fix indentation in add-on translations
  Some lines in the translation dict were off by a few spaces. This
  resulted in linting tools complaining about the indentation.

- Do not escape messages in add-on translations multiple times
  When extracting add-on messages, they would get escaped multiple
  times, resulting in invalid strings when they contained quotes for
  example.

  This happened because on updating the messages from the ref
  ones (those actually extracted from Blender), each ref I18nMessage
  would be assigned to the corresponding language I18nMessage, without
  copy. When this message was escaped, it happened once for every
  language since they were actually the same object.

  To avoid this, I18nMessage objects are copied when merging.

-----

Example tuple before PR:
```python
translations_tuple = (
    (("*", ""),
     ((), ()),
     ("fr_FR", "Project-Id-Version: AnimAll 0...1.1...0 (0)\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2024-05-26 17:10+0000\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME <EMAIL@ADDRESS>\nLanguage-Team: LANGUAGE <LL@li.org>\nLanguage: __POT__\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit",
               (False,
                ("Blender's translation file (po format).",
                 "Copyright (C) 2024 The Blender Authors.",
                 "This file is distributed under the same license as the Blender package.",
                 "FIRST AUTHOR <EMAIL@ADDRESS>, YEAR."))),
    ),
    (("*", "\\"Location\\" and \\"Shape Key\\" are redundant?"),
     (("extensions/user_default/animall/__init__.py:250",),
      ()),
     ("fr_FR", "",
               (False, ())),
    ),
    ...
```

After:
```python
translations_tuple = (
    (("*", ""),
     ((), ()),
     ("fr_FR", "Project-Id-Version: AnimAll 0.11.0 (0)\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2024-05-26 17:06+0000\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME <EMAIL@ADDRESS>\nLanguage-Team: LANGUAGE <LL@li.org>\nLanguage: __POT__\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit",
      (False, ("FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.",))),
     ),
    (("*", "\"Location\" and \"Shape Key\" are redundant?"),
     (("extensions/user_default/animall/__init__.py:250",),
      ()),
     ("fr_FR", "",
      (False, ())),
     ),
    ...
```

Pull Request: https://projects.blender.org/blender/blender/pulls/122273
2024-05-27 13:33:49 +02:00
..
__init__.py License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
bl_extract_messages.py I18n: improve add-on translation tooling 2024-05-27 13:33:49 +02:00
merge_po.py License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
settings_user.py License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
settings.py Fix/tweak UI messages (typos etc.). 2024-03-04 11:17:55 +01:00
utils_cli.py I18n Py Module: Update settings after move to Weblate. 2023-09-15 18:08:52 +02:00
utils_languages_menu.py Cleanup: unused imports 2024-04-19 16:09:30 +10:00
utils_rtl.py Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
utils_spell_check.py Fix/tweak UI messages (typos etc.). 2024-03-04 11:17:55 +01:00
utils.py I18n: improve add-on translation tooling 2024-05-27 13:33:49 +02:00