Improve auto-translation of editor's top & bottom bars

- The main menu
- The run bar
- The update spinner
- The bottom panel buttons
This commit is contained in:
Haoyu Qiu 2025-06-17 16:41:42 +08:00
parent 46c495ca21
commit 1301343f42
22 changed files with 87 additions and 77 deletions

View file

@ -306,7 +306,7 @@ EditorBottomPanel::EditorBottomPanel() {
item_vbox->add_child(bottom_hbox);
left_button = memnew(Button);
left_button->set_tooltip_text(TTR("Scroll Left\nHold Ctrl to scroll to the begin.\nHold Shift to scroll one page."));
left_button->set_tooltip_text(TTRC("Scroll Left\nHold Ctrl to scroll to the begin.\nHold Shift to scroll one page."));
left_button->set_accessibility_name(TTRC("Scroll Left"));
left_button->set_theme_type_variation("BottomPanelButton");
left_button->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
@ -323,7 +323,7 @@ EditorBottomPanel::EditorBottomPanel() {
bottom_hbox->add_child(button_scroll);
right_button = memnew(Button);
right_button->set_tooltip_text(TTR("Scroll Right\nHold Ctrl to scroll to the end.\nHold Shift to scroll one page."));
right_button->set_tooltip_text(TTRC("Scroll Right\nHold Ctrl to scroll to the end.\nHold Shift to scroll one page."));
right_button->set_accessibility_name(TTRC("Scroll Right"));
right_button->set_theme_type_variation("BottomPanelButton");
right_button->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
@ -355,7 +355,7 @@ EditorBottomPanel::EditorBottomPanel() {
pin_button->hide();
pin_button->set_theme_type_variation("FlatMenuButton");
pin_button->set_toggle_mode(true);
pin_button->set_tooltip_text(TTR("Pin Bottom Panel Switching"));
pin_button->set_tooltip_text(TTRC("Pin Bottom Panel Switching"));
pin_button->set_accessibility_name(TTRC("Pin Bottom Panel"));
pin_button->connect(SceneStringName(toggled), callable_mp(this, &EditorBottomPanel::_pin_button_toggled));

View file

@ -119,15 +119,15 @@ void EditorRunBar::_reset_play_buttons() {
play_button->set_pressed(false);
play_button->set_button_icon(get_editor_theme_icon(SNAME("MainPlay")));
play_button->set_tooltip_text(TTR("Play the project."));
play_button->set_tooltip_text(TTRC("Play the project."));
play_scene_button->set_pressed(false);
play_scene_button->set_button_icon(get_editor_theme_icon(SNAME("PlayScene")));
play_scene_button->set_tooltip_text(TTR("Play the edited scene."));
play_scene_button->set_tooltip_text(TTRC("Play the edited scene."));
play_custom_scene_button->set_pressed(false);
play_custom_scene_button->set_button_icon(get_editor_theme_icon(SNAME("PlayCustom")));
play_custom_scene_button->set_tooltip_text(TTR("Play a custom scene."));
play_custom_scene_button->set_tooltip_text(TTRC("Play a custom scene."));
}
void EditorRunBar::_update_play_buttons() {
@ -152,7 +152,7 @@ void EditorRunBar::_update_play_buttons() {
if (active_button) {
active_button->set_pressed(true);
active_button->set_button_icon(get_editor_theme_icon(SNAME("Reload")));
active_button->set_tooltip_text(TTR("Reload the played scene."));
active_button->set_tooltip_text(TTRC("Reload the played scene."));
}
}
@ -518,6 +518,7 @@ EditorRunBar::EditorRunBar() {
// Use a button for the indicator since it comes with a background panel and pixel perfect centering of an icon.
profiler_autostart_indicator = memnew(Button);
profiler_autostart_indicator->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
profiler_autostart_indicator->set_icon_alignment(HORIZONTAL_ALIGNMENT_CENTER);
profiler_autostart_indicator->set_focus_mode(FOCUS_ACCESSIBILITY);
profiler_autostart_indicator->set_theme_type_variation("ProfilerAutostartIndicator");
@ -678,6 +679,6 @@ EditorRunBar::EditorRunBar() {
write_movie_panel->add_child(write_movie_button);
write_movie_button->set_theme_type_variation("RunBarButtonMovieMakerDisabled");
write_movie_button->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
write_movie_button->set_tooltip_text(TTR("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file."));
write_movie_button->set_tooltip_text(TTRC("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file."));
write_movie_button->set_accessibility_name(TTRC("Enable Movie Maker Mode"));
}

View file

@ -236,12 +236,12 @@ void EditorToaster::_auto_hide_or_free_toasts() {
}
if (toasts.is_empty()) {
main_button->set_tooltip_text(TTR("No notifications."));
main_button->set_tooltip_text(TTRC("No notifications."));
main_button->set_modulate(Color(0.5, 0.5, 0.5));
main_button->set_disabled(true);
set_process_internal(false);
} else {
main_button->set_tooltip_text(TTR("Show notifications."));
main_button->set_tooltip_text(TTRC("Show notifications."));
main_button->set_modulate(Color(1, 1, 1));
main_button->set_disabled(false);
}
@ -342,6 +342,7 @@ void EditorToaster::_repop_old() {
Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_time, const String &p_tooltip) {
// Create the panel according to the severity.
PanelContainer *panel = memnew(PanelContainer);
panel->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
panel->set_tooltip_text(p_tooltip);
switch (p_severity) {
case SEVERITY_INFO:
@ -435,10 +436,12 @@ void EditorToaster::_popup_str(const String &p_message, Severity p_severity, con
hb->add_theme_constant_override("separation", 0);
Label *label = memnew(Label);
label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
label->set_focus_mode(FOCUS_ACCESSIBILITY);
hb->add_child(label);
Label *count_label = memnew(Label);
count_label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
hb->add_child(count_label);
control = popup(hb, p_severity, default_message_duration, p_tooltip);
@ -576,7 +579,7 @@ EditorToaster::EditorToaster() {
// Main button.
main_button = memnew(Button);
main_button->set_accessibility_name(TTRC("Notifications"));
main_button->set_tooltip_text(TTR("No notifications."));
main_button->set_tooltip_text(TTRC("No notifications."));
main_button->set_modulate(Color(0.5, 0.5, 0.5));
main_button->set_disabled(true);
main_button->set_theme_type_variation("FlatMenuButton");
@ -593,7 +596,7 @@ EditorToaster::EditorToaster() {
disable_notifications_button = memnew(Button);
disable_notifications_button->set_accessibility_name(TTRC("Silence Notifications"));
disable_notifications_button->set_tooltip_text(TTR("Silence the notifications."));
disable_notifications_button->set_tooltip_text(TTRC("Silence the notifications."));
disable_notifications_button->set_flat(true);
disable_notifications_button->connect(SceneStringName(pressed), callable_mp(this, &EditorToaster::_set_notifications_enabled).bind(false));
disable_notifications_panel->add_child(disable_notifications_button);

View file

@ -64,6 +64,16 @@ void EditorVersionButton::_notification(int p_what) {
set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
set_text(_get_version_string(format));
} break;
case NOTIFICATION_TRANSLATION_CHANGED: {
String build_date;
if (GODOT_VERSION_TIMESTAMP > 0) {
build_date = Time::get_singleton()->get_datetime_string_from_unix_time(GODOT_VERSION_TIMESTAMP, true) + " UTC";
} else {
build_date = TTR("(unknown)");
}
set_tooltip_text(vformat(TTR("Git commit date: %s\nClick to copy the version information."), build_date));
} break;
}
}
@ -74,12 +84,4 @@ void EditorVersionButton::pressed() {
EditorVersionButton::EditorVersionButton(VersionFormat p_format) {
format = p_format;
set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
String build_date;
if (GODOT_VERSION_TIMESTAMP > 0) {
build_date = Time::get_singleton()->get_datetime_string_from_unix_time(GODOT_VERSION_TIMESTAMP, true) + " UTC";
} else {
build_date = TTR("(unknown)");
}
set_tooltip_text(vformat(TTR("Git commit date: %s\nClick to copy the version information."), build_date));
}