74 Commits

Author SHA1 Message Date
Damien Picard
19b9ea72b0 I18n: extract keymap preferences
The per-keymap user preferences messages were not extracted. This goes
through the keymap preferences RNA, as well as Python files for UI.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15871
2022-09-05 15:37:09 +02:00
Campbell Barton
24b8ccaa94 Cleanup: format 2022-08-30 16:22:49 +10:00
Damien Picard
73bfd8058f I18n: make add-ons' info translatable
The info provided by add-ons is very valuable to users, yet it wasn’t translatable yet.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15747
2022-08-29 14:12:21 +02:00
Campbell Barton
649807a8cd Cleanup: format 2022-08-24 09:22:26 +10:00
Damien Picard
4ac96a483b I18n: make workspaces translatable
This makes workspaces more translatable:
- New Workspace menu
  - header
  - preset menus
  - preset entries
- workspace names upon factory file template load
- new workspace name upon workspace addition

To properly translate those names, an extraction function for
workspace names from app templates was added as well.

(Do not do anything when loading a user-saved file!)

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15727
2022-08-23 11:54:34 +02:00
Damien Picard
af59e32c13 I18n: make more parts of the UI translatable
- "Name collisions" label in mesh properties
- "Threshold" labels in Vertex Weight Edit modifier
- "Particle System" label in Particle Instance modifier
- Slot number in the Shader Editor

- Status bar keymap items during modal operations:
  add TIP_() macro to status bar interface template

- On dumping messages, sort preset files so their messages are stable
  between runs

Ref. T43295

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15607
2022-08-09 21:07:32 +10:00
Bastien Montagne
2de1b06287 I18n: add extraction of modal event names.
Alternative fix to the one proposed in D15607.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D15643
2022-08-09 21:07:32 +10:00
Damien Picard
a2bdd6a71a I18n: remove Window class from message extraction blacklist
Messages from the bpy.types.Window class were blacklisted in the
message extraction script.

This change allows a few new messages to be translated, including at
least two which show up in the UI. There are only 12 new messages in
the .po files, so even if some never need to be translated, that's not
too many.

Ref. T43295

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15628
2022-08-09 21:07:32 +10:00
Damien Picard
3239cea726 I18n: make presets translatable
Presets are used all over the Blender UI, but were so far untranslatable.

This adds the translation code as well as a new `dump_preset_messages()` function in the message extraction. This goes over all bundled preset file names and extracts them.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15570
2022-08-01 14:09:41 +02:00
Damien Picard
c48dc61749 I18n: fixes to add-on message extraction
This commit fixes several issues in add-ons UI messages extraction code:

- In multi-file modules, the script would crash because it tried to write to
  the dir instead of a `translations.py` file;
- The add-on message extraction works by enabling the add-on, getting all
  messages; disabling the add-on, getting all messages; then comparing the
  two message sets. But often a bug happens where a class gets a
  description from somewhere else in memory. I couldn’t debug that, so a
  workaround is to check that the message isn’t a corrupted one before
  removing it;
- `printf()` doesn't exist in Python and would crash the script;
- `self.src[self.settings.PARSER_PY_ID]` can be replaced by `self.py_file`
  in class `I18n`, since a property exists to do that;
- At one point a generator was printed instead of its values, so let's
  unpack the generator to get the values. Maybe the print could be
  deleted entirely;
- Use SPDX license identifier instead of GPL license block, to be more in
  line with other scripts from the codebase.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15474
2022-07-20 11:05:07 +02:00
Bastien Montagne
e69c4482f1 I18n: Add suport for labels from modifiers' subpanels.
Was a bit oif a struggle since those functions take a first string which
is not our label, but should work fine now.

Reported/detected as part of D15418.
2022-07-15 11:42:58 +02:00
Campbell Barton
3ca76ae0e8 Cleanup: remove "<pep8 compliant>" from headers
It can be assumed that all scripts comply with basic pep8 formatting
regarding white-space, indentation etc.

Also remove note in best practices page & update `tests/python/pep8.py`.

If we want to exclude some scripts from make format,
this can be done by adding them to `ignore_files` in:
source/tools/utils_maintenance/autopep8_format_paths.py

Or using `# nopep8` for to ignore for individual lines.

Ref T98554
2022-06-02 20:16:20 +10:00
Bastien Montagne
b8432c2c8e Tweak i18n messages extraction script to avoid unwanted messages.
Code would add a bit too often the identifier of an RNA class to
translated messages, this is only needed if there is no valid label
available for it.
2022-05-09 12:40:26 +02:00
Bastien Montagne
0d0a45b89d Fix/workaround i18n script not finding some messages anymore.
For some reasons(c) some base classes (like `bpy.types.Modifier`) are
not listed anymore by a call to
`bpy.types.ID.__base__.__subclasses__()`, unless they are first accessed
explicitely (e.g. by executing `bpy.types.Modifier` etc.).
2022-04-11 15:45:52 +02:00
Campbell Barton
c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
luzpaz
dea26253a0 cleanup: fix typos in comments and docs
Followup to https://developer.blender.org/D10288

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D10346
2021-11-16 18:45:10 -05:00
Bastien Montagne
2ecaa971f0 I18n: Fix several issues with UI messages extraction script.
* Fix systematic skipping of labels when they are the same as
  the identifier (Some cases are valid, like `RGB` or `HSV` e.g.).
* Add instead heuristics checks to skip non-UI properties (non-capitalized,
  or same name as identifier and Operator properties, mainly).
* Skip `bl_icon` and `icon` properties.
* Properly search for properties in all parent classes (some cases with
  e.g. `Panel` would break due to intermediary utils classes, leading to
  those internal UI properties not being skipped as expected).

Related to T43295.
2021-11-03 16:13:46 +01:00
Campbell Barton
e288e392a8 Cleanup: line length in Python scripts 2021-10-24 21:04:04 +11:00
Bastien Montagne
23d9953c80 I18n tools: Fix issue when extracting messages on release builds.
This was also affecting prototype of buildbot-driven UI messages
extraction...
2021-10-04 12:17:50 +02:00
Campbell Barton
37793b90be Cleanup: unused imports 2021-03-06 19:26:18 +11:00
Bastien Montagne
32073993a8 i18n messages extraction script: fix handling of C unicode-escapes.
rB1f5647c07d15 introduced for the first time a unicode escape in strings
to be translated, directly extracted from C-code itself.

This revealed that this case was not properly handled by current code,
for now we work around using `raw_unicode_escape` encoding/decoding of
python.
2021-02-22 18:32:49 +01:00
Bastien Montagne
623ddc4aa6 Fix i18n messages extraction tool after update to support py 3.10.
The new defferred approach broke existing way to access items from
struct definition...

See T85872.
2021-02-22 12:20:25 +01:00
Bastien Montagne
626a9aae6d Fix part of T84004: Some 2.92 alpha UI strings can't be translated.
Adding 'new' (?) `heading` parameter of some UILayout functions...
2020-12-21 11:50:38 +01:00
Campbell Barton
41d2d6da0c Cleanup: pep8 (indentation, spacing, long lines) 2020-10-02 11:59:16 +10:00
Bastien Montagne
9d674708ea Fix T80589: Translations in python scripts are missing.
Python 3.8 changed handling of constant values in its AST tool.
This code should work on both officialy supported 3.7, and newer 3.8,
for now.
2020-09-13 19:50:08 +02:00
Bastien Montagne
9607e54985 Fix T74959: Need to be explicit about UTF8 encoding in py.
Because some OSs are still using old 8bits specific encodings... Angry
eye @windows...
2020-03-20 20:52:52 +01:00
Bastien Montagne
d119e163d0 Fix many typos and other issues in UI messages. 2020-02-17 13:01:07 +01:00
Campbell Barton
5a541cfcec Cleanup: resolve static analyzer warnings in bl_i18n_utils
Reported in T73504
2020-01-30 11:48:26 +11:00
Bastien Montagne
22d157d469 I18n: dirty workaround for PITA ghost classes remaining after unregister.
Spent again a whole day trying to understand what happens here, with no
luck. For some reasons, OperatorProperties children of unregistered
operator classes remain accessible, with their `bl_rna` member, although
that one is 100% invalid (freed memory, crashes with ASAN builds).

Funny thing is, I cannot reproduce that situation when disabling the
add-on from the py console of a Blender-with-UI.

Note: issue revealed by X3D add-on, which is still enabled in factory
settings, while not being officially supported any more, this has to be
fixed in a separate commit.
2019-09-09 17:42:44 +02:00
Bastien Montagne
4cbcbacc6a I18n messages extraction: do not report multi-lines messages anymore.
Those are now supported for tooltips.
2019-08-01 12:52:52 +02:00
Bastien Montagne
4b37abd61f Cleanup a bit i18n message extraction code. 2019-08-01 12:52:52 +02:00
Bastien Montagne
a4869df4c9 I18n messages extraction: add 'generic' handling of Tools. 2019-03-31 18:49:11 +02:00
Campbell Barton
bbe98b18fb Cleanup: use preferences prefix for Python operators 2019-03-02 00:23:42 +11:00
Bastien Montagne
59b530ca18 Fix and workaround for i18n messages extraction code. 2018-12-23 22:03:43 +01:00
Campbell Barton
916446e83f Cleanup: move keymap hierarchy into own file 2018-11-20 11:38:13 +11:00
Campbell Barton
1c3411ac89 Keymap: expose tool keymaps in the preferences
Currently some modes share tool keymaps, we might want to disable
this since it's confusing editing one thing in multiple places.

However this should be resolved in the tool definitions.
2018-10-03 15:55:57 +10:00
Campbell Barton
09aa446100 Merge branch 'master' into blender2.8 2018-09-13 20:15:18 +10:00
Campbell Barton
ff432a410a PyAPI: use brief description for operator repr
Only include description in docstring.

Also avoid using op_get_rna.
2018-09-13 19:59:15 +10:00
Bastien Montagne
a43ebc63fa Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/collision.c
2018-09-03 17:44:36 +02:00
Brecht Van Lommel
4da2acae3a Spelling fixes in comments and descriptions, patch by luzpaz.
Differential Revision: https://developer.blender.org/D3668
2018-09-03 16:55:01 +02:00
Campbell Barton
80a31d30a4 Merge branch 'master' into blender2.8 2018-07-07 08:53:00 +02:00
Campbell Barton
4b373ed086 Cleanup: pep8 2018-07-07 08:48:35 +02:00
Brecht Van Lommel
74fd17e9d7 UI/Python: rename Lamps to Lights, to follow more standard terminology.
Internally it's still mostly named lamps, though some modules like Cycles
were already calling them lights.
2018-07-06 20:06:09 +02:00
Bastien Montagne
a22af1a84b Fix i18n messages extraction script, and a few more UI messages... 2017-10-04 12:39:06 +02:00
Bastien Montagne
1a1bcad43a Fix T49158: Untranslatable elements in UI.
We cannot skip 'collections clesse' when generating i18n messages from RNA, some of them
are visible and UI...
2016-08-26 15:46:56 +02:00
Bastien Montagne
fe8b197269 Fix T49150: make new 'operator categories' in search menu i18n-aware. 2016-08-23 21:48:16 +02:00
Bastien Montagne
337b718695 Fix T47371 - add access to 'static' enum items.
Some dynamic enums, which do not need a valid context pointer, have their 'itemf'
callback always called. This is annoying for introspection tools (like the ones generating
translations, or API documentation), because it means they never have access to all possible
options (enum items).

So now, there is also an `enum_items_static` accessor to get only statically-defined
enum items.

Note: only i18n tools take advantage of this currently, others are still to be updated.

Reviewers: campbellbarton, sergey

Differential Revision: https://developer.blender.org/D1782
2016-02-09 12:51:07 +01:00
Bastien Montagne
46a7b46c30 Fix broken i18n messages extracting script with new py code.
Some py devs are way too smart for our own good... :P
2016-01-14 17:00:16 +01:00
Bastien Montagne
2eb0c990f1 i18n extraction tools: keep even better order of entries in PO files.
Important to avoid too much changes, especially on the git repo (we are still getting
way too much changes there currently...).
2015-09-28 20:32:09 +02:00
Bastien Montagne
451a077511 I18n extract: better handling of commandline args. 2015-06-03 17:15:00 +02:00