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

Remove translation change notification when setting the locale of a Translation resource #34587

Conversation

YeldhamDev
Copy link
Member

@YeldhamDev YeldhamDev commented Dec 24, 2019

I've spend a hour trying to find the source of a bug in my code as to why NOTIFICATION_TRANSLATION_CHANGED was being triggered when I was not changing the game's locale. The cause? Apparently loading a Translation resource via code triggers the set_locale() method in it, triggering the notification.

While I get it why it triggers it when changing the locale of the whole game (via TranslationServer), triggering the notification by changing the locale of a resource doesn't make much sense to me.

@akien-mga
Copy link
Member

It makes sense to me, NOTIFICATION_TRANSLATION_CHANGED doesn't only mean that the language changed, but it can mean that new translation resources have been loaded for the current locale and the scene's strings should thus be reloaded to take potential changes into account. (I did not look deep into it though so I might be missing something in this specific case.)

@YeldhamDev
Copy link
Member Author

But the simple act of loading a translation resource (not adding it to the TranslationServer, just loading it) triggers it, and it's quite an annoyance when you have to load them at runtime.

@YeldhamDev YeldhamDev force-pushed the translation_resource_notification_removal branch from fbed541 to f065171 Compare January 2, 2020 16:11
@YeldhamDev
Copy link
Member Author

I changed the commit to make the translation notification only emit if the resource is loaded in the TranslationServer. I don't see any other case where that would be useful otherwise.

@YeldhamDev YeldhamDev force-pushed the translation_resource_notification_removal branch from f065171 to a9be7e4 Compare May 17, 2020 13:39
…nslation resource only happen when loaded in the server
@YeldhamDev YeldhamDev force-pushed the translation_resource_notification_removal branch from a9be7e4 to 4f08174 Compare November 8, 2020 14:55
@Calinou Calinou added this to the 4.0 milestone Jan 5, 2021
@akien-mga akien-mga requested review from akien-mga and reduz February 25, 2021 15:42
@akien-mga
Copy link
Member

The change makes sense to me, let's try to get @reduz to glance at it too to confirm that this was the intent for this notification. The documentation for NOTIFICATION_TRANSLATION_CHANGED in Node and MainLoop should likely also be clarified.

@YeldhamDev
Copy link
Member Author

The documentation for NOTIFICATION_TRANSLATION_CHANGED in Node and MainLoop should likely also be clarified.

I'm quite sure nobody expects that to trigger when loading the resource itself to begin with.

@akien-mga akien-mga merged commit 8fb382a into godotengine:master Mar 22, 2021
@akien-mga
Copy link
Member

Thanks!

@YeldhamDev YeldhamDev deleted the translation_resource_notification_removal branch March 22, 2021 23:07
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.

4 participants