Make editor use translation domains

How editor plugins use this feature:
1. Pick a unique translation domain name.
2. `_enter_tree()`: load translations into that translation domain.
3. Call `set_translation_domain()` for its root UI node.
4. `_exit_tree()`: remove that translation domain.

Plugins can also set the translation domain to `godot.editor` for
nested nodes that should use editor translations. `EditorFileDialog`
automatically does this.
This commit is contained in:
Haoyu Qiu
2024-08-16 22:19:14 +08:00
parent c5d147b9b5
commit 818acb4290
10 changed files with 38 additions and 125 deletions

View File

@@ -207,6 +207,10 @@ void EditorFileDialog::_update_theme_item_cache() {
void EditorFileDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POSTINITIALIZE: {
set_translation_domain(SNAME("godot.editor"));
} break;
case NOTIFICATION_THEME_CHANGED:
case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_TRANSLATION_CHANGED: {