1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Improve auto-translation of main screens

This commit is contained in:
kobewi
2025-05-30 00:10:53 +02:00
parent b89c47bb85
commit bc6f0d29cc
3 changed files with 241 additions and 202 deletions

View File

@@ -98,7 +98,7 @@ public:
VBoxContainer *container;
GridContainer *child_container;
set_title(TTR("Configure Snap"));
set_title(TTRC("Configure Snap"));
container = memnew(VBoxContainer);
add_child(container);
@@ -108,7 +108,7 @@ public:
container->add_child(child_container);
label = memnew(Label);
label->set_text(TTR("Grid Offset:"));
label->set_text(TTRC("Grid Offset:"));
child_container->add_child(label);
label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -135,7 +135,7 @@ public:
child_container->add_child(grid_offset_y);
label = memnew(Label);
label->set_text(TTR("Grid Step:"));
label->set_text(TTRC("Grid Step:"));
child_container->add_child(label);
label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -160,7 +160,7 @@ public:
child_container->add_child(grid_step_y);
label = memnew(Label);
label->set_text(TTR("Primary Line Every:"));
label->set_text(TTRC("Primary Line Every:"));
label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(label);
@@ -180,7 +180,7 @@ public:
primary_grid_step_y->set_step(1);
primary_grid_step_y->set_max(SPIN_BOX_GRID_RANGE);
primary_grid_step_y->set_allow_greater(true);
primary_grid_step_y->set_suffix("steps");
primary_grid_step_y->set_suffix(TTRC("steps")); // TODO: Add suffix auto-translation.
primary_grid_step_y->set_h_size_flags(Control::SIZE_EXPAND_FILL);
primary_grid_step_y->set_select_all_on_focus(true);
primary_grid_step_y->set_accessibility_name(TTRC("Y Primary Step"));
@@ -195,28 +195,28 @@ public:
container->add_child(child_container);
label = memnew(Label);
label->set_text(TTR("Rotation Offset:"));
label->set_text(TTRC("Rotation Offset:"));
child_container->add_child(label);
label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rotation_offset = memnew(SpinBox);
rotation_offset->set_min(-SPIN_BOX_ROTATION_RANGE);
rotation_offset->set_max(SPIN_BOX_ROTATION_RANGE);
rotation_offset->set_suffix("deg");
rotation_offset->set_suffix(U"°");
rotation_offset->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rotation_offset->set_select_all_on_focus(true);
rotation_offset->set_accessibility_name(TTRC("Rotation Offset"));
child_container->add_child(rotation_offset);
label = memnew(Label);
label->set_text(TTR("Rotation Step:"));
label->set_text(TTRC("Rotation Step:"));
child_container->add_child(label);
label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rotation_step = memnew(SpinBox);
rotation_step->set_min(-SPIN_BOX_ROTATION_RANGE);
rotation_step->set_max(SPIN_BOX_ROTATION_RANGE);
rotation_step->set_suffix("deg");
rotation_step->set_suffix(U"°");
rotation_step->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rotation_step->set_select_all_on_focus(true);
rotation_step->set_accessibility_name(TTRC("Rotation Step"));
@@ -228,7 +228,7 @@ public:
child_container->set_columns(2);
container->add_child(child_container);
label = memnew(Label);
label->set_text(TTR("Scale Step:"));
label->set_text(TTRC("Scale Step:"));
child_container->add_child(label);
label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -2479,17 +2479,17 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
if (b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::RIGHT) {
add_node_menu->clear();
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Add")), TTR("Add Node Here..."), ADD_NODE);
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Instance")), TTR("Instantiate Scene Here..."), ADD_INSTANCE);
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Add")), TTRC("Add Node Here..."), ADD_NODE);
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Instance")), TTRC("Instantiate Scene Here..."), ADD_INSTANCE);
for (Node *node : SceneTreeDock::get_singleton()->get_node_clipboard()) {
if (Object::cast_to<CanvasItem>(node)) {
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ActionPaste")), TTR("Paste Node(s) Here"), ADD_PASTE);
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ActionPaste")), TTRC("Paste Node(s) Here"), ADD_PASTE);
break;
}
}
for (Node *node : EditorNode::get_singleton()->get_editor_selection()->get_top_selected_node_list()) {
if (Object::cast_to<CanvasItem>(node)) {
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ToolMove")), TTR("Move Node(s) Here"), ADD_MOVE);
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ToolMove")), TTRC("Move Node(s) Here"), ADD_MOVE);
break;
}
}
@@ -4140,6 +4140,11 @@ void CanvasItemEditor::_project_settings_changed() {
void CanvasItemEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
select_button->set_tooltip_text(keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Alt+Drag: Scale selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + TTR("(Available in all modes.)") + "\n" + TTR("RMB: Add node at position clicked."));
pivot_button->set_tooltip_text(TTR("Click to change object's pivot.") + "\n" + TTR("Shift: Set temporary pivot.") + "\n" + TTR("Click this button while holding Shift to put the temporary pivot in the center of the selected nodes."));
} break;
case NOTIFICATION_READY: {
_update_lock_and_group_button();
@@ -5430,6 +5435,7 @@ CanvasItemEditor::CanvasItemEditor() {
viewport->add_child(controls_vb);
select_button = memnew(Button);
select_button->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
select_button->set_theme_type_variation(SceneStringName(FlatButton));
main_menu_hbox->add_child(select_button);
select_button->set_toggle_mode(true);
@@ -5437,7 +5443,6 @@ CanvasItemEditor::CanvasItemEditor() {
select_button->set_pressed(true);
select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTRC("Select Mode"), Key::Q, true));
select_button->set_shortcut_context(this);
select_button->set_tooltip_text(keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Alt+Drag: Scale selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + TTR("(Available in all modes.)") + "\n" + TTR("RMB: Add node at position clicked."));
select_button->set_accessibility_name(TTRC("Select Mode"));
main_menu_hbox->add_child(memnew(VSeparator));
@@ -5479,15 +5484,15 @@ CanvasItemEditor::CanvasItemEditor() {
main_menu_hbox->add_child(list_select_button);
list_select_button->set_toggle_mode(true);
list_select_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_LIST_SELECT));
list_select_button->set_tooltip_text(TTR("Show list of selectable nodes at position clicked."));
list_select_button->set_tooltip_text(TTRC("Show list of selectable nodes at position clicked."));
list_select_button->set_accessibility_name(TTRC("List Selectable Nodes"));
pivot_button = memnew(Button);
pivot_button->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
pivot_button->set_theme_type_variation(SceneStringName(FlatButton));
main_menu_hbox->add_child(pivot_button);
pivot_button->set_toggle_mode(true);
pivot_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_EDIT_PIVOT));
pivot_button->set_tooltip_text(TTR("Click to change object's pivot.") + "\n" + TTR("Shift: Set temporary pivot.") + "\n" + TTR("Click this button while holding Shift to put the temporary pivot in the center of the selected nodes."));
pivot_button->set_accessibility_name(TTRC("Change Pivot"));
pan_button = memnew(Button);
@@ -5538,7 +5543,7 @@ CanvasItemEditor::CanvasItemEditor() {
snap_config_menu->set_shortcut_context(this);
main_menu_hbox->add_child(snap_config_menu);
snap_config_menu->set_h_size_flags(SIZE_SHRINK_END);
snap_config_menu->set_tooltip_text(TTR("Snapping Options"));
snap_config_menu->set_tooltip_text(TTRC("Snapping Options"));
snap_config_menu->set_switch_on_hover(true);
snap_config_menu->set_accessibility_name(TTRC("Snapping Options"));
@@ -5559,7 +5564,7 @@ CanvasItemEditor::CanvasItemEditor() {
smartsnap_config_popup->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_node_center", TTRC("Snap to Node Center")), SNAP_USE_NODE_CENTER);
smartsnap_config_popup->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_other_nodes", TTRC("Snap to Other Nodes")), SNAP_USE_OTHER_NODES);
smartsnap_config_popup->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_guides", TTRC("Snap to Guides")), SNAP_USE_GUIDES);
p->add_submenu_node_item(TTR("Smart Snapping"), smartsnap_config_popup);
p->add_submenu_node_item(TTRC("Smart Snapping"), smartsnap_config_popup);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/configure_snap", TTRC("Configure Snap...")), SNAP_CONFIGURE);
@@ -5610,7 +5615,7 @@ CanvasItemEditor::CanvasItemEditor() {
skeleton_menu->set_theme_type_variation("FlatMenuButton");
skeleton_menu->set_shortcut_context(this);
main_menu_hbox->add_child(skeleton_menu);
skeleton_menu->set_tooltip_text(TTR("Skeleton Options"));
skeleton_menu->set_tooltip_text(TTRC("Skeleton Options"));
skeleton_menu->set_switch_on_hover(true);
skeleton_menu->set_accessibility_name(TTRC("Skeleton Options"));
@@ -5627,7 +5632,7 @@ CanvasItemEditor::CanvasItemEditor() {
view_menu->set_flat(false);
view_menu->set_theme_type_variation("FlatMenuButton");
// TRANSLATORS: Noun, name of the 2D/3D View menus.
view_menu->set_text(TTR("View"));
view_menu->set_text(TTRC("View"));
view_menu->set_switch_on_hover(true);
view_menu->set_shortcut_context(this);
main_menu_hbox->add_child(view_menu);
@@ -5640,12 +5645,12 @@ CanvasItemEditor::CanvasItemEditor() {
grid_menu = memnew(PopupMenu);
grid_menu->connect("about_to_popup", callable_mp(this, &CanvasItemEditor::_prepare_grid_menu));
grid_menu->connect(SceneStringName(id_pressed), callable_mp(this, &CanvasItemEditor::_on_grid_menu_id_pressed));
grid_menu->add_radio_check_item(TTR("Show"), GRID_VISIBILITY_SHOW);
grid_menu->add_radio_check_item(TTR("Show When Snapping"), GRID_VISIBILITY_SHOW_WHEN_SNAPPING);
grid_menu->add_radio_check_item(TTR("Hide"), GRID_VISIBILITY_HIDE);
grid_menu->add_radio_check_item(TTRC("Show"), GRID_VISIBILITY_SHOW);
grid_menu->add_radio_check_item(TTRC("Show When Snapping"), GRID_VISIBILITY_SHOW_WHEN_SNAPPING);
grid_menu->add_radio_check_item(TTRC("Hide"), GRID_VISIBILITY_HIDE);
grid_menu->add_separator();
grid_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/toggle_grid", TTRC("Toggle Grid"), KeyModifierMask::CMD_OR_CTRL | Key::APOSTROPHE));
p->add_submenu_node_item(TTR("Grid"), grid_menu);
p->add_submenu_node_item(TTRC("Grid"), grid_menu);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTRC("Show Helpers"), Key::H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTRC("Show Rulers")), SHOW_RULERS);
@@ -5663,7 +5668,7 @@ CanvasItemEditor::CanvasItemEditor() {
gizmos_menu->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_group_gizmos", TTRC("Group")), SHOW_GROUP_GIZMOS);
gizmos_menu->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_transformation_gizmos", TTRC("Transformation")), SHOW_TRANSFORMATION_GIZMOS);
p->add_child(gizmos_menu);
p->add_submenu_item(TTR("Gizmos"), "GizmosMenu");
p->add_submenu_item(TTRC("Gizmos"), "GizmosMenu");
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTRC("Center Selection"), Key::F), VIEW_CENTER_TO_SELECTION);
@@ -5674,10 +5679,10 @@ CanvasItemEditor::CanvasItemEditor() {
theme_menu = memnew(PopupMenu);
theme_menu->connect(SceneStringName(id_pressed), callable_mp(this, &CanvasItemEditor::_switch_theme_preview));
theme_menu->add_radio_check_item(TTR("Project theme"), THEME_PREVIEW_PROJECT);
theme_menu->add_radio_check_item(TTR("Editor theme"), THEME_PREVIEW_EDITOR);
theme_menu->add_radio_check_item(TTR("Default theme"), THEME_PREVIEW_DEFAULT);
p->add_submenu_node_item(TTR("Preview Theme"), theme_menu);
theme_menu->add_radio_check_item(TTRC("Project theme"), THEME_PREVIEW_PROJECT);
theme_menu->add_radio_check_item(TTRC("Editor theme"), THEME_PREVIEW_EDITOR);
theme_menu->add_radio_check_item(TTRC("Default theme"), THEME_PREVIEW_DEFAULT);
p->add_submenu_node_item(TTRC("Preview Theme"), theme_menu);
theme_preview = (ThemePreviewMode)(int)EditorSettings::get_singleton()->get_project_metadata("2d_editor", "theme_preview", THEME_PREVIEW_PROJECT);
for (int i = 0; i < THEME_PREVIEW_MAX; i++) {
@@ -5705,7 +5710,7 @@ CanvasItemEditor::CanvasItemEditor() {
key_loc_button->set_pressed(true);
key_loc_button->set_focus_mode(FOCUS_NONE);
key_loc_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_POS));
key_loc_button->set_tooltip_text(TTR("Translation mask for inserting keys."));
key_loc_button->set_tooltip_text(TTRC("Translation mask for inserting keys."));
key_loc_button->set_accessibility_name(TTRC("Translation Mask"));
animation_hb->add_child(key_loc_button);
@@ -5715,7 +5720,7 @@ CanvasItemEditor::CanvasItemEditor() {
key_rot_button->set_pressed(true);
key_rot_button->set_focus_mode(FOCUS_NONE);
key_rot_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_ROT));
key_rot_button->set_tooltip_text(TTR("Rotation mask for inserting keys."));
key_rot_button->set_tooltip_text(TTRC("Rotation mask for inserting keys."));
key_rot_button->set_accessibility_name(TTRC("Rotation Mask"));
animation_hb->add_child(key_rot_button);
@@ -5724,7 +5729,7 @@ CanvasItemEditor::CanvasItemEditor() {
key_scale_button->set_toggle_mode(true);
key_scale_button->set_focus_mode(FOCUS_NONE);
key_scale_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_SCALE));
key_scale_button->set_tooltip_text(TTR("Scale mask for inserting keys."));
key_scale_button->set_tooltip_text(TTRC("Scale mask for inserting keys."));
key_scale_button->set_accessibility_name(TTRC("Scale Mask"));
animation_hb->add_child(key_scale_button);
@@ -5752,7 +5757,7 @@ CanvasItemEditor::CanvasItemEditor() {
animation_menu->set_flat(false);
animation_menu->set_theme_type_variation("FlatMenuButton");
animation_menu->set_shortcut_context(this);
animation_menu->set_tooltip_text(TTR("Animation Key and Pose Options"));
animation_menu->set_tooltip_text(TTRC("Animation Key and Pose Options"));
animation_menu->set_accessibility_name(TTRC("Animation Key and Pose"));
animation_hb->add_child(animation_menu);
animation_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &CanvasItemEditor::_popup_callback));
@@ -6427,7 +6432,6 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(CanvasItemEditor *p_canvas_it
texture_node_type_selector = memnew(AcceptDialog);
EditorNode::get_singleton()->get_gui_base()->add_child(texture_node_type_selector);
texture_node_type_selector->set_title(TTR("Change Default Type"));
texture_node_type_selector->connect(SceneStringName(confirmed), callable_mp(this, &CanvasItemEditorViewport::_on_change_type_confirmed));
texture_node_type_selector->connect("canceled", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_closed));
@@ -6444,10 +6448,11 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(CanvasItemEditor *p_canvas_it
button_group.instantiate();
for (int i = 0; i < texture_node_types.size(); i++) {
CheckBox *check = memnew(CheckBox);
btn_group->add_child(check);
check->set_text(texture_node_types[i]);
check->connect("button_down", callable_mp(this, &CanvasItemEditorViewport::_on_select_texture_node_type).bind(check));
check->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
check->set_button_group(button_group);
btn_group->add_child(check);
check->connect("button_down", callable_mp(this, &CanvasItemEditorViewport::_on_select_texture_node_type).bind(check));
}
label = memnew(Label);