24 Commits

Author SHA1 Message Date
Campbell Barton
682e5e3597 Cleanup: spelling in comments (make check_spelling_*) 2025-04-26 00:48:04 +00:00
Campbell Barton
ec40ad0b3f Cleanup: use str.format to format strings in Python 2025-01-31 13:22:10 +11:00
Campbell Barton
6ca1417103 Cleanup: suppress unused Python warnings
Suppress unused warnings using the "vulture" utility.

- Include public definitions in the modules `__all__`.
- Mark arguments & variables as unused with a "_" prefix.
2024-12-03 12:54:13 +11:00
Campbell Barton
d920ef5425 Merge branch 'blender-v4.3-release' 2024-11-03 22:04:44 +11:00
Campbell Barton
b00550916c PyDoc: correct use of single back-ticks 2024-11-03 21:50:33 +11:00
Campbell Barton
6d1e235f15 Cleanup: remove use of deprecated typing from scripts/modules/
Also use comments for typing that can't be checked.
2024-10-18 10:43:14 +11:00
Campbell Barton
a7ab81d927 PyAPI: remove use of BaseException
BaseException was used as a catch-all in situations where it
didn't make sense and where "Exception" is more appropriate
based on Python's documentation & error checking tools,
`pylint` warns `broad-exception-caught` for e.g.

BaseException includes SystemExit, KeyboardInterrupt & GeneratorExit,
so unless the intention is to catch calls to `sys.exit(..)`,
breaking a out of a loop using Ctrl-C or generator-exit,
then it shouldn't be used.

Even then, it's preferable to catch those exceptions explicitly.
2024-10-01 13:18:46 +10:00
Bastien Montagne
81cdcf8326 Fix (unreported) I18N tool failing to process RTL languages on Linux. 2024-09-16 12:41:11 +02:00
Campbell Barton
8a7ff41a85 Cleanup: wrap long lines in Python scripts 2024-08-19 10:48:07 +10:00
Bastien Montagne
7d52265771 Fix several issues with i18n tools on non-linux platforms.
- Paths of C++-parsed files were not properly 'unixified' on Windows.
  This was bad both for changes noisyness in PO files, and broke on
  the un-escaping of `\n` and `\t` sequences.
- The `ProcessPoolExecutor` starts sub-processes differently on Linux
  than on Windows or OSX. While Linux's `fork` keeps the same
  environment (i.e. all Blender stuff remains available in workers
  subprocesses), the 'spawn' used on Windows (and reportedly OSX) starts
  a new bare python interpreter. This means that code executed by these
  needs to be Blender-agnostic to be portable.

The only thing that is currently known broken on non-Linux platforms is
the RTL processing of some languages like Arabic or Hebrew.
2024-08-10 17:35:28 +02:00
Bastien Montagne
1e5d1c0d04 Fix (unreported) I18N error when generating messages for an add-on.
Would error when a language is not selected in the translation UI, and
new messages are generated by the update.
2024-06-04 18:42:17 +02:00
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
Andrej730
a8e14af167 bl_i18n_utils - bugs saving translations to py files and finding po strings if context is not present in the file
4 changes in this PR:

1) Fixed bug with saving translations to py files - saving sources and comments it didn't add `repr` for the saved strings which was producing unexpected special characters.

Then these special characters sometimes made `translations.py` invalid (e.g., it was failing to load with some `\u` combinations) or was producing invalid characters in .po files created from the `translations.py`.

2) `find_best_messages_matches` used to fail when current message context wasn't found in the .po file. E.g. there were no messages with context "View3D", "Operator", ... and you would try to edit translation for the element that uses that context. I've added a fallback to empty sets to make sure it won't fail and just return the valid result that there are no matches.

3) added minor typing hint for easier code navigation.

4) added print to make it clear what data is printed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116934
2024-02-06 16:58:47 +01:00
Campbell Barton
a8e73616b9 Cleanup: rename add-on related variables for clarity
- Rename info to bl_info, to avoid confusion with extensions manifest,
  which should eventually be accessible in a similar way.
- Rename module_name to addon_module_name to avoid confusion with
  extension repositories name-spaced modules.
- Clarify naming for TOML manifest.
2024-02-01 17:03:40 +11:00
Bastien Montagne
f9c3d51322 I18N: utils: Fix invalid timestamp format in PO files.
Expected format is `%Y-%m-%d %H:%M%z`.

Previous code would not generate the expected format of timestamps for
PO files headers (specifically in the the `POT-Creation-Date` field).

This could lead to some parsers (like e.g. the `sphinx_intl.load_po`
function) failing to load these PO files.

Note: since `datetime` module requires additional gymnastic to get valid
timezone info,switched back to the simpler `time` module here.

All times are expressed in UTC (aka GMT) timezone, since these are also
the values stored for Blender buildtimes.

Reported by @hoanguk in the Blender translations chat, thanks.
2024-01-18 11:20:26 +01:00
Bastien Montagne
0ce02355c1 I18N module: updates for transition to weblate.
Remove `es_ES` language.
Rename `uz_UZ` to `uz_UZ@latin`
Rename `zh_CN` to `zh_HANS`
Rename `zh_TW` to `zh_HANT`

Add support for lowercase chars in `country` part of the locale code
(although in the end it is not needed, since `boost::locale` backend
does not supports lowercase 'country' part in locales identifiers
currently) .

Related to https://projects.blender.org/infrastructure/blender-projects-platform/issues/65
2023-09-15 18:08:52 +02:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton
53e6803977 Cleanup: check for "BaseException" instead of "Exception"
Prefer the more generic exception type as it's possible exceptions
derive from this and not "Exception".

Also use the name 'ex' for exceptions instead of 'e'.
2023-07-30 16:14:13 +10:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Campbell Barton
c4c1cc7cd3 Cleanup: double quotes for non-enum strings
Also use back-ticks for code-references in comments.
2023-04-18 10:51:32 +10:00
Bastien Montagne
48979c6cdc Py module i18n utils: return subprocess.run result to catch output of external commands.
Avoids having prints in random order in multi-processes concurrent
context.
2023-04-17 14:38:51 +02:00
Campbell Barton
e1ab9e352c Cleanup: autopep8 2023-03-01 22:12:18 +11:00
Sergey Sharybin
03806d0b67 Re-design of submodules used in blender.git
This commit implements described in the #104573.

The goal is to fix the confusion of the submodule hashes change, which are not
ideal for any of the supported git-module configuration (they are either always
visible causing confusion, or silently staged and committed, also causing
confusion).

This commit replaces submodules with a checkout of addons and addons_contrib,
covered by the .gitignore, and locale and developer tools are moved to the
main repository.

This also changes the paths:
- /release/scripts are moved to the /scripts
- /source/tools are moved to the /tools
- /release/datafiles/locale is moved to /locale

This is done to avoid conflicts when using bisect, and also allow buildbot to
automatically "recover" wgen building older or newer branches/patches.

Running `make update` will initialize the local checkout to the changed
repository configuration.

Another aspect of the change is that the make update will support Github style
of remote organization (origin remote pointing to thy fork, upstream remote
pointing to the upstream blender/blender.git).

Pull Request #104755
2023-02-21 16:39:58 +01:00