Skip to content

Fix CSV translation not updating after reimport #107410

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

timothyqiu
Copy link
Member

@timothyqiu timothyqiu commented Jun 11, 2025

Follow-up to #96921.

One of the known issues is updating CSV translations don't update preview text in the editor.

Fix updating CSV translation files not updating preview text in the editor

Unlike .po files, importing a .csv file as translations does not "import" the file as any resource. The .translation files are extra files generated during the "import as nothing" process.

A non-imported resource file is only reloaded if the file's last modified time change. I think this logic was only considering external changes to resource files since the editor hooks into the resource saving process, tracking the file's last modified time automatically. So the newly generated .translation files won't be reloaded as the file's last modified time is always up-to-date.

Fortunately, Resource tracks its last modified time too. So we can compare the file's last modified time with the cached resource's last modified time.

This PR forces a reload of the resource caches corresponding to the generated files at the end of the import process.

Only update translation when necessary

Currently, NOTIFICATION_TRANSLATION_CHANGED is propagated in the editing scene tree whenever project settings change. This is unnecessary and could make the stuttering worse if the editing scene is very complex.

In this PR, when project settings change, the notification is propagated only if the translation file set of the currently previewing locale is changed.

In order to compare HashSet equality, I added operator{==,!=} for it and related tests.

Simplify the preview toggle logic

Originally, the translation preview PR turns translation preview on/off by updating the editing scene root's auto translation mode. Later, this was changed to disabling the entire translation domain for identifier-based translation.

The change made changing auto translation mode unnecessary, but this fact was made less obvious by some optimization logic :(


Here is a test project with a demo scene showing translatable texts from PO and CSV files: test-4.zip

@timothyqiu timothyqiu requested review from a team as code owners June 11, 2025 14:38
Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to HashSet is fine.
Still needs a proper review of the rest of the code.

@Repiteo Repiteo merged commit 4587ecb into godotengine:master Jun 18, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 18, 2025

Thanks!

@timothyqiu timothyqiu deleted the csv-reload branch June 19, 2025 00:14
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.

5 participants