Skip to content

Commit 8a04e33

Browse files
committed
Merge pull request #109153 from timothyqiu/replication-editor-auto-translation
Improve auto-translation of the replication editor
2 parents ac641b1 + cbd3528 commit 8a04e33

File tree

4 files changed

+46
-36
lines changed

4 files changed

+46
-36
lines changed

editor/editor_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8398,7 +8398,7 @@ EditorNode::EditorNode() {
83988398

83998399
warning = memnew(AcceptDialog);
84008400
warning->set_unparent_when_invisible(true);
8401-
warning->add_button(TTR("Copy Text"), true, "copy");
8401+
warning->add_button(TTRC("Copy Text"), true, "copy");
84028402
warning->connect("custom_action", callable_mp(this, &EditorNode::_copy_warning));
84038403

84048404
ED_SHORTCUT("editor/next_tab", TTRC("Next Scene Tab"), KeyModifierMask::CTRL + Key::TAB);

editor/inspector/property_selector.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ void PropertySelector::_sbox_input(const Ref<InputEvent> &p_event) {
6868

6969
void PropertySelector::_update_search() {
7070
if (properties) {
71-
set_title(TTR("Select Property"));
71+
set_title(TTRC("Select Property"));
7272
} else if (virtuals_only) {
73-
set_title(TTR("Select Virtual Method"));
73+
set_title(TTRC("Select Virtual Method"));
7474
} else {
75-
set_title(TTR("Select Method"));
75+
set_title(TTRC("Select Method"));
7676
}
7777

7878
search_options->clear();
@@ -668,7 +668,6 @@ void PropertySelector::_bind_methods() {
668668
PropertySelector::PropertySelector() {
669669
VBoxContainer *vbc = memnew(VBoxContainer);
670670
add_child(vbc);
671-
//set_child_rect(vbc);
672671
search_box = memnew(LineEdit);
673672
search_box->set_accessibility_name(TTRC("Search:"));
674673
search_box->set_clear_button_enabled(true);
@@ -677,8 +676,8 @@ PropertySelector::PropertySelector() {
677676
vbc->add_margin_child(TTRC("Search:"), search_box);
678677
search_options = memnew(Tree);
679678
search_options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
680-
vbc->add_margin_child(TTR("Matches:"), search_options, true);
681-
set_ok_button_text(TTR("Open"));
679+
vbc->add_margin_child(TTRC("Matches:"), search_options, true);
680+
set_ok_button_text(TTRC("Open"));
682681
get_ok_button()->set_disabled(true);
683682
register_text_enter(search_box);
684683
set_hide_on_ok(false);
@@ -689,5 +688,5 @@ PropertySelector::PropertySelector() {
689688
help_bit = memnew(EditorHelpBit);
690689
help_bit->set_content_height_limits(80 * EDSCALE, 80 * EDSCALE);
691690
help_bit->connect("request_hide", callable_mp(this, &PropertySelector::_hide_requested));
692-
vbc->add_margin_child(TTR("Description:"), help_bit);
691+
vbc->add_margin_child(TTRC("Description:"), help_bit);
693692
}

editor/scene/scene_tree_editor.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,9 +2256,8 @@ void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) {
22562256
content->move_child(allowed_types_hbox, 0);
22572257

22582258
{
2259-
Label *label = memnew(Label);
2259+
Label *label = memnew(Label(TTRC("Allowed:")));
22602260
allowed_types_hbox->add_child(label);
2261-
label->set_text(TTR("Allowed:"));
22622261
}
22632262

22642263
HFlowContainer *hflow = memnew(HFlowContainer);
@@ -2373,7 +2372,7 @@ void SceneTreeDialog::_bind_methods() {
23732372
}
23742373

23752374
SceneTreeDialog::SceneTreeDialog() {
2376-
set_title(TTR("Select a Node"));
2375+
set_title(TTRC("Select a Node"));
23772376
content = memnew(VBoxContainer);
23782377
add_child(content);
23792378

@@ -2382,7 +2381,7 @@ SceneTreeDialog::SceneTreeDialog() {
23822381

23832382
filter = memnew(LineEdit);
23842383
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2385-
filter->set_placeholder(TTR("Filter Nodes"));
2384+
filter->set_placeholder(TTRC("Filter Nodes"));
23862385
filter->set_clear_button_enabled(true);
23872386
filter->add_theme_constant_override("minimum_character_width", 0);
23882387
filter->connect(SceneStringName(text_changed), callable_mp(this, &SceneTreeDialog::_filter_changed));
@@ -2394,7 +2393,7 @@ SceneTreeDialog::SceneTreeDialog() {
23942393

23952394
// Add 'Show All' button to HBoxContainer next to the filter, visible only when valid_types is defined.
23962395
show_all_nodes = memnew(CheckButton);
2397-
show_all_nodes->set_text(TTR("Show All"));
2396+
show_all_nodes->set_text(TTRC("Show All"));
23982397
show_all_nodes->connect(SceneStringName(toggled), callable_mp(this, &SceneTreeDialog::_show_all_nodes_changed));
23992398
show_all_nodes->set_h_size_flags(Control::SIZE_SHRINK_BEGIN);
24002399
show_all_nodes->hide();

modules/multiplayer/editor/replication_editor.cpp

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ void ReplicationEditor::_pick_node_selected(NodePath p_path) {
105105

106106
void ReplicationEditor::_pick_new_property() {
107107
if (current == nullptr) {
108-
EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it."));
108+
EditorNode::get_singleton()->show_warning(TTRC("Select a replicator node in order to pick a property to add to it."));
109109
return;
110110
}
111111
Node *root = current->get_node(current->get_root_path());
112112
if (!root) {
113-
EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root."));
113+
EditorNode::get_singleton()->show_warning(TTRC("Not possible to add a new property to synchronize without a root."));
114114
return;
115115
}
116116
pick_node->popup_scenetree_dialog(nullptr, current);
@@ -122,7 +122,7 @@ void ReplicationEditor::_add_sync_property(String p_path) {
122122
config = current->get_replication_config();
123123

124124
if (config.is_valid() && config->has_property(p_path)) {
125-
EditorNode::get_singleton()->show_warning(TTR("Property is already being synchronized."));
125+
EditorNode::get_singleton()->show_warning(TTRC("Property is already being synchronized."));
126126
return;
127127
}
128128

@@ -166,7 +166,7 @@ ReplicationEditor::ReplicationEditor() {
166166

167167
pick_node = memnew(SceneTreeDialog);
168168
add_child(pick_node);
169-
pick_node->set_title(TTR("Pick a node to synchronize:"));
169+
pick_node->set_title(TTRC("Pick a node to synchronize:"));
170170
pick_node->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_selected));
171171
pick_node->get_filter_line_edit()->connect(SceneStringName(text_changed), callable_mp(this, &ReplicationEditor::_pick_node_filter_text_changed));
172172

@@ -223,15 +223,14 @@ ReplicationEditor::ReplicationEditor() {
223223
HBoxContainer *hb = memnew(HBoxContainer);
224224
vb->add_child(hb);
225225

226-
add_pick_button = memnew(Button);
226+
add_pick_button = memnew(Button(TTRC("Add property to sync...")));
227227
add_pick_button->connect(SceneStringName(pressed), callable_mp(this, &ReplicationEditor::_pick_new_property));
228-
add_pick_button->set_text(TTR("Add property to sync..."));
229228
hb->add_child(add_pick_button);
230229

231230
VSeparator *vs = memnew(VSeparator);
232231
vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0));
233232
hb->add_child(vs);
234-
hb->add_child(memnew(Label(TTR("Path:"))));
233+
hb->add_child(memnew(Label(TTRC("Path:"))));
235234

236235
np_line_edit = memnew(LineEdit);
237236
np_line_edit->set_placeholder(":property");
@@ -240,9 +239,8 @@ ReplicationEditor::ReplicationEditor() {
240239
np_line_edit->connect(SceneStringName(text_submitted), callable_mp(this, &ReplicationEditor::_np_text_submitted));
241240
hb->add_child(np_line_edit);
242241

243-
add_from_path_button = memnew(Button);
242+
add_from_path_button = memnew(Button(TTRC("Add from path")));
244243
add_from_path_button->connect(SceneStringName(pressed), callable_mp(this, &ReplicationEditor::_add_pressed));
245-
add_from_path_button->set_text(TTR("Add from path"));
246244
hb->add_child(add_from_path_button);
247245

248246
vs = memnew(VSeparator);
@@ -252,19 +250,19 @@ ReplicationEditor::ReplicationEditor() {
252250
pin = memnew(Button);
253251
pin->set_theme_type_variation(SceneStringName(FlatButton));
254252
pin->set_toggle_mode(true);
255-
pin->set_tooltip_text(TTR("Pin replication editor"));
253+
pin->set_tooltip_text(TTRC("Pin replication editor"));
256254
hb->add_child(pin);
257255

258256
tree = memnew(Tree);
259257
tree->set_hide_root(true);
260258
tree->set_columns(4);
261259
tree->set_column_titles_visible(true);
262-
tree->set_column_title(0, TTR("Properties"));
260+
tree->set_column_title(0, TTRC("Properties"));
263261
tree->set_column_expand(0, true);
264-
tree->set_column_title(1, TTR("Spawn"));
262+
tree->set_column_title(1, TTRC("Spawn"));
265263
tree->set_column_expand(1, false);
266264
tree->set_column_custom_minimum_width(1, 100);
267-
tree->set_column_title(2, TTR("Replicate"));
265+
tree->set_column_title(2, TTRC("Replicate"));
268266
tree->set_column_custom_minimum_width(2, 100);
269267
tree->set_column_expand(2, false);
270268
tree->set_column_expand(3, false);
@@ -274,9 +272,8 @@ ReplicationEditor::ReplicationEditor() {
274272
tree->set_v_size_flags(SIZE_EXPAND_FILL);
275273
vb->add_child(tree);
276274

277-
drop_label = memnew(Label);
275+
drop_label = memnew(Label(TTRC("Add properties using the options above, or\ndrag them from the inspector and drop them here.")));
278276
drop_label->set_focus_mode(FOCUS_ACCESSIBILITY);
279-
drop_label->set_text(TTR("Add properties using the options above, or\ndrag them from the inspector and drop them here."));
280277
drop_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
281278
drop_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
282279
tree->add_child(drop_label);
@@ -313,12 +310,12 @@ bool ReplicationEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &
313310

314311
void ReplicationEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
315312
if (current == nullptr) {
316-
EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it."));
313+
EditorNode::get_singleton()->show_warning(TTRC("Select a replicator node in order to pick a property to add to it."));
317314
return;
318315
}
319316
Node *root = current->get_node(current->get_root_path());
320317
if (!root) {
321-
EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root."));
318+
EditorNode::get_singleton()->show_warning(TTRC("Not possible to add a new property to synchronize without a root."));
322319
return;
323320
}
324321

@@ -345,8 +342,21 @@ void ReplicationEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_da
345342
_add_sync_property(path);
346343
}
347344

345+
void _set_replication_mode_options(TreeItem *p_item) {
346+
p_item->set_text(2, TTR("Never", "Replication Mode") + "," + TTR("Always", "Replication Mode") + "," + TTR("On Change", "Replication Mode"));
347+
}
348+
348349
void ReplicationEditor::_notification(int p_what) {
349350
switch (p_what) {
351+
case NOTIFICATION_TRANSLATION_CHANGED: {
352+
TreeItem *root = tree->get_root();
353+
if (root) {
354+
for (TreeItem *ti = root->get_first_child(); ti; ti = ti->get_next()) {
355+
_set_replication_mode_options(ti);
356+
}
357+
}
358+
} break;
359+
350360
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
351361
if (!EditorThemeManager::is_generated_theme_outdated()) {
352362
break;
@@ -363,17 +373,17 @@ void ReplicationEditor::_notification(int p_what) {
363373

364374
void ReplicationEditor::_add_pressed() {
365375
if (!current) {
366-
EditorNode::get_singleton()->show_warning(TTR("Please select a MultiplayerSynchronizer first."));
376+
EditorNode::get_singleton()->show_warning(TTRC("Please select a MultiplayerSynchronizer first."));
367377
return;
368378
}
369379
if (current->get_root_path().is_empty()) {
370-
EditorNode::get_singleton()->show_warning(TTR("The MultiplayerSynchronizer needs a root path."));
380+
EditorNode::get_singleton()->show_warning(TTRC("The MultiplayerSynchronizer needs a root path."));
371381
return;
372382
}
373383
String np_text = np_line_edit->get_text();
374384

375385
if (np_text.is_empty()) {
376-
EditorNode::get_singleton()->show_warning(TTR("Property/path must not be empty."));
386+
EditorNode::get_singleton()->show_warning(TTRC("Property/path must not be empty."));
377387
return;
378388
}
379389

@@ -420,7 +430,7 @@ void ReplicationEditor::_tree_item_edited() {
420430
int old_value = config->property_get_replication_mode(prop);
421431
// We have a hard limit of 64 watchable properties per synchronizer.
422432
if (value == SceneReplicationConfig::REPLICATION_MODE_ON_CHANGE && config->get_watch_properties().size() >= 64) {
423-
EditorNode::get_singleton()->show_warning(TTR("Each MultiplayerSynchronizer can have no more than 64 watched properties."));
433+
EditorNode::get_singleton()->show_warning(TTRC("Each MultiplayerSynchronizer can have no more than 64 watched properties."));
424434
ti->set_range(column, old_value);
425435
return;
426436
}
@@ -552,6 +562,7 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn,
552562
item->set_selectable(2, false);
553563
item->set_selectable(3, false);
554564
item->set_text(0, prop);
565+
item->set_auto_translate_mode(0, AUTO_TRANSLATE_MODE_DISABLED);
555566
item->set_metadata(0, prop);
556567
Node *root_node = current && !current->get_root_path().is_empty() ? current->get_node(current->get_root_path()) : nullptr;
557568
Ref<Texture2D> icon = _get_class_icon(root_node);
@@ -568,7 +579,7 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn,
568579
Variant value = node->get(subpath, &valid);
569580
if (valid && !can_sync(value)) {
570581
item->set_icon(0, get_theme_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons)));
571-
item->set_tooltip_text(0, TTR("Property of this type not supported."));
582+
item->set_tooltip_text(0, TTRC("Property of this type not supported."));
572583
} else {
573584
item->set_icon(0, icon);
574585
}
@@ -583,7 +594,8 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn,
583594
item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_CENTER);
584595
item->set_cell_mode(2, TreeItem::CELL_MODE_RANGE);
585596
item->set_range_config(2, 0, 2, 1);
586-
item->set_text(2, TTR("Never", "Replication Mode") + "," + TTR("Always", "Replication Mode") + "," + TTR("On Change", "Replication Mode"));
597+
item->set_auto_translate_mode(2, AUTO_TRANSLATE_MODE_DISABLED);
598+
_set_replication_mode_options(item);
587599
item->set_range(2, (int)p_mode);
588600
item->set_editable(2, true);
589601
}

0 commit comments

Comments
 (0)