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

Include example of handling run-time translation changes in a script #647

Closed
Calinou opened this issue Aug 31, 2021 · 3 comments
Closed
Milestone

Comments

@Calinou
Copy link
Member

Calinou commented Aug 31, 2021

Which demo project is affected: Translation Demo

Description:

The Translation demo should include an example of handling translation changes for a custom control in a script.

See https://godotforums.org/discussion/27323/acessing-translations-and-new-scenes where I had to devise some custom code for this, but I don't know if it actually works. Cross-posting it here for posterity:

# Stores the text that is displayed to the user.
var text = "" setget set_text

# Stores the translation key.
var original_text = ""

func set_text(p_text):
    text = tr(p_text)
    original_text = p_text

func _notification(what):
    if what == NOTIFICATION_TRANSLATION_CHANGED:
        self.text = tr(original_text)
@voylin
Copy link
Contributor

voylin commented Apr 3, 2022

Made a PR with an example similar to this. I hope that the PR has what you wanted. ^^

@voylin
Copy link
Contributor

voylin commented Apr 7, 2022

I think this issue can be closed now, right?

@aaronfranke
Copy link
Member

Fixed by #716.

@aaronfranke aaronfranke added this to the 4.0 milestone Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants