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

Add auto translate mode for tooltips #97406

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

timothyqiu
Copy link
Member

@timothyqiu timothyqiu commented Sep 24, 2024

Supersedes #97265

This PR adds tooltip_auto_translate_mode to Control. This auto translate mode is applied to the tooltip control, whether the default Label, or custom one returned by _make_custom_tooltip.

Since the tooltip control is a descendant of its owning control, AUTO_TRANSLATE_MODE_INHERIT works as expected.

Rationale:

It's not uncommon for tooltips to show dynamic content. Example in editor codebase (C++):

version_btn->set_tooltip_text(vformat(TTR("Git commit date: %s\nClick to copy the version information."), build_date));

In this kind of usage:

  • tooltip text has to be translated manually
  • tooltip auto translation should be disabled in order to avoid double translation
  • it's not related to whether the control itself should auto translated

The second problem this PR solves is the same as described in #97265:

Tooltip text could be pure data instead of text-to-display in order to do customization via _make_custom_tooltip(). Thus, we should not translate them immediately through atr().

@timothyqiu
Copy link
Member Author

I still get translated text in _make_custom_tooltip() though.

How is your scene setup?

I tested with tooltip.zip and it works fine.

@KoBeWi
Copy link
Member

KoBeWi commented Sep 26, 2024

Works fine with #97397 (I was testing with Button).

@timothyqiu
Copy link
Member Author

Ah yeah, currently button's shortcut_in_tooltip is implemented by calling the button's atr() directly.

@akien-mga akien-mga merged commit 01d567b into godotengine:master Sep 26, 2024
19 checks passed
@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.

3 participants