Skip to content
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

i18n: Make property paths and categories translatable #58706

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

timothyqiu
Copy link
Member

master version of #58634

They are basically the same except master supports plural message and optional message context, so I modified the regex.

# Regex "(?P<name>(?:[^"\\]|\\.)*)" creates a group named `name` that matches a string.
message_patterns = {
re.compile(r'RTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): False,
re.compile(r'TTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): False,
re.compile(r'TTRC\("(?P<message>(?:[^"\\]|\\.)*)"\)'): False,
re.compile(
r'TTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
): False,
re.compile(
r'RTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
): False,
re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): True,
re.compile(r'GLOBAL_DEF(?:_RST)?\("(?P<message>[^".]+?)",'): True,
re.compile(r'EDITOR_DEF(?:_RST)?\("(?P<message>[^"]+?)",'): True,
re.compile(r'ADD_PROPERTY\(PropertyInfo\(Variant::[A-Z]+,\s*"(?P<message>[^"]+?)",'): True,
re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)",'): False,
}

Seems a bit long and messy because I gave each capture group an explicit name (?P<name>expression) so it's easier to handle plural message and optional message context.

Tested message extraction without the property path patterns. The result is the same as the original approach except for one message which is fixed in #58705.

@timothyqiu timothyqiu added this to the 4.0 milestone Mar 3, 2022
@timothyqiu timothyqiu requested a review from a team as a code owner March 3, 2022 10:45
@akien-mga akien-mga merged commit 7e4a8d3 into godotengine:master Mar 10, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants