-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POT Generator: Add support for TRANSLATORS:
and NO_TRANSLATE
comments
#98099
POT Generator: Add support for TRANSLATORS:
and NO_TRANSLATE
comments
#98099
Conversation
8402557
to
2f1d828
Compare
Just curious, because it's missing from the examples: what happens to comments surrounding a single line with 2 tr()'s? Eg:
And when there's both a comment above and behind?
|
This will be applied to both strings, the parser does not check if the comment is consumed. But you can write: print(
tr("key_here"), # TRANSLATORS: hello
tr("another_key"), # TRANSLATORS: world
) or: print(
# TRANSLATORS: hello
tr("key_here"),
# TRANSLATORS: world
tr("another_key"),
)
Inline comment takes precedence, comment above will not be used. |
b2b6514
to
c37d2f3
Compare
In your example, print(tr("tr8", "ctx_c")) # TRANSLATORS: Message 8.1
print(tr("tr8", "ctx_c")) # TRANSLATORS: Message 8.2 generates #. TRANSLATORS: Message 8.1
#. TRANSLATORS: Message 8.2
#: node.gd
msgctxt "ctx_c"
msgid "tr8"
msgstr "" This makes the translators comment
The expected result is
|
@timothyqiu I wasn't sure if we need remove the |
print(tr("tr8", "ctx_c")) # TRANSLATORS: Message 8.1
print(tr("tr8", "ctx_c")) # TRANSLATORS: Message 8.2 @dalexeev I mean, the message Perhaps the |
c37d2f3
to
5dc6e83
Compare
@timothyqiu Done, updated the example. |
I think we should have a separate color for built-in comment keywords to distinguish them from user ones. I have a local branch for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested some common use cases locally, and it worked as expected.
5dc6e83
to
cab80cb
Compare
Fixed a case I forgot about (non-inline comment should only be taken into account if there is no code in that line). print(tr("tr10")) # TRANSLATORS: Message 10
print(tr("tr11")) |
This falls into the same category as translation context: godotengine/godot-proposals#8061 Currently, there are several one-to-many / many-to-one situations that need to be sorted out. I don't think node's auto translate system is ready for this. At least it should be a separate PR, it's not very GDScript related :P |
@timothyqiu Yes, it is indeed not very relevant to this PR. I want to reset the translation content generation process of the entire UI system, so that it can automatically collect the marked multilingual information from tscn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Does this also works for |
I thought we would add this to the online documentation, but maybe we should add it to the class reference as well. However, I'm concerned that this is only useful for POT users, and is useless for CSV. Also, the plugin recognizes many patterns, |
I don't see a natural place to include it in the class reference indeed, but there should be a section about translator comments added to https://docs.godotengine.org/en/stable/tutorials/i18n/localization_using_gettext.html Then maybe we can also ensure this page or the whole i18n section is properly linked in relevant parts of the classref, like maybe the |
I don't know if a thumbs-up gives it justice but it's my thoughts exactly. |
Thanks! |
I completely missed this PR but this needs some fixes to handle extensions due to the fact that we cannot pass arrays and data to extensions, see: So this will need a fix for these cases as well for 4.4 or these won't work as far as I can tell Edit: Haven't confirmed but this might have been fixed in: But made a PR for changing the signature of this in any case to ensure proper function, especially as it should only be partially "fixed" (you need to |
I'll write up a dedicated fix for just these methods to get it in quickly |
Example