Repository navigation
Conversation
Documentation build overview
151 files changed ·
|
…rtifact paths alphabetically in pyproject.toml
| """Export translated singular JavaScript messages from the compiled catalog.""" | ||
| mofile = pofile.with_suffix(".mo") | ||
| jsfile = pofile.with_suffix(".js") | ||
| if not mofile.exists(): | ||
| jsfile.unlink(missing_ok=True) | ||
| return |
There was a problem hiding this comment.
We could simplify this function to only read the .po file, and skip the fuzzy/untranslated messages, rather than also reading the compiled .mo file?
| """Export translated singular JavaScript messages from the compiled catalog.""" | |
| mofile = pofile.with_suffix(".mo") | |
| jsfile = pofile.with_suffix(".js") | |
| if not mofile.exists(): | |
| jsfile.unlink(missing_ok=True) | |
| return | |
| """Export translated singular JavaScript messages from the catalog.""" | |
| jsfile = pofile.with_suffix(".js") |
There was a problem hiding this comment.
Thanks for suggestion, applied. On the other hand using .mo makes us reusing the same configuration of catalog compilation, but it's not worth the complication probably.
| with mofile.open("rb") as f: | ||
| compiled = read_mo(f) |
There was a problem hiding this comment.
| with mofile.open("rb") as f: | |
| compiled = read_mo(f) |
| compiled = read_mo(f) | ||
| messages = {} | ||
| for message in source: | ||
| if not isinstance(message.id, str): |
There was a problem hiding this comment.
| if not isinstance(message.id, str): | |
| if not isinstance(message.id, str) or message.fuzzy or not message.string: |
| translation = compiled.get(message.id) | ||
| if translation is not None and translation.string: | ||
| messages[message.id] = translation.string |
There was a problem hiding this comment.
| translation = compiled.get(message.id) | |
| if translation is not None and translation.string: | |
| messages[message.id] = translation.string | |
| messages[message.id] = message.string |
| import tomllib | ||
| from pathlib import Path | ||
|
|
||
| from babel.messages.mofile import read_mo |
There was a problem hiding this comment.
| from babel.messages.mofile import read_mo |
|
Thanks for doing the work @m-aciek! I should have time tomorrow for a review :) |
Affirm-Session: 01a20a8a-1869-7c52-8e68-246dde4499c5
Affirm-Session: 01a20a8a-1869-7c52-8e68-246dde4499c5
tomasr8
left a comment
There was a problem hiding this comment.
Looks good, but I'll let Hugo have another look :)
| for message in source: | ||
| if not any(filename.endswith(".js") for filename, _ in message.locations): | ||
| continue | ||
| if message.context is not None or message.fuzzy or not message.string: |
There was a problem hiding this comment.
Maybe I'd just add a comment mentioning we skip pgettext and why
There was a problem hiding this comment.
👍 I've added: skip messages with context: Sphinx's JavaScript gettext runtime doesn't provide pgettext().
There was a problem hiding this comment.
Update: also splitted the condition and simplified to Sphinx's JavaScript gettext runtime doesn't provide pgettext().
Alternative to #337.
Add and mount missing JS translations catalog. Extraction was/is working correctly.