bl_i18n_utils - bugs saving translations to py files and finding po strings if context is not present in the file #116934
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116934
Loading…
Reference in New Issue
No description provided.
Delete Branch "Andrej730/blender:bl_i18n_utils_bugs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
4 changes in this PR:
repr
for the saved strings which was producing unexpected special characters:Then those 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 thetranslations.py
.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.added minor typing hint for easier code navigation.
added print to make it clear what data is printed.
Generally looks great, thanks for the patch (and sorry for the review delay).
Just noted a couple of details below.
@ -782,3 +783,3 @@
if elbl:
# Enum items' labels have no i18n context...
k = ctxt_to_msg[self.settings.DEFAULT_CONTEXT].copy()
k = ctxt_to_msg.get(self.settings.DEFAULT_CONTEXT, set()).copy()
I would rather ensure that
self.settings.DEFAULT_CONTEXT
is always present inctxt_to_msg
(i.e. add it systematically with an emptyset
as value ininvalidate_reverse_cache
).That way there is only needs for a default argument top
get
in one place.Makes sense, it will be much more clean that way.
Resolved it in
4382d70808
👍@ -1250,3 +1251,3 @@
def __init__(self, kind=None, src=None, langs=set(), settings=settings):
self.settings = settings
self.trans = {}
self.trans: Dict[str, I18nMessages] = {}
I'd rather have a comment than this type hint, not a big fan of these (at all).
Are you sure? The idea was that IDE would identify
self.trans
values asI18nMessages
and it would be easier to navigate to the methods and attributes of those instances in for-loops overself.trans
.I just don't like this syntax... Feels just as horrible as C++ templates. I guess since I do not use a real IDE for python, I don't get that help either.
If you really want to keep it, I can live with it though, I know that I'm on the dinosaurs side on this topic.
(I assume this is a fix for #116579 ?)
No, it's a separate issue.
ffd2048daa
- ensure default context is always present instead of using fallback values@pioverfour FYI since you also work a lot on this tool these days, and in case you want to check. For me it's good to go.
This change makes sense at a glance, I’ll test it tomorrow.
Even without this quote issue, I think a better fix would be to normalize file paths to use POSIX separators ("/" instead of "\"). That way, if developers using Windows and Unix-like systems work on the same add-on, they don’t have to bother fixing the paths.
@Andrej730 This should work but I can’t test it on Windows, let me know what you think:
The rest is nice :)
0ceed7caf6
and change saved source paths to posix instead@pioverfour makes complete sense, that's much more direct fix, tested it! And it would also allow (in theory) different users to generate exactly the same
translations.py
, even if they use different systems which is pretty cool (and would be a problem I'd meet sooner or later 😅).@mont29 Hi! Does this PR needs more approves or it's ready to merge?
@Andrej730 Sorry for the delay! Maybe @pioverfour wants to do another final check before this gets merged?
Looks good to me!