|
@@ -1127,7 +1127,11 @@ void ProjectSettingsEditor::_translation_res_option_changed() {
|
|
ERR_FAIL_COND(!remaps.has(key));
|
|
ERR_FAIL_COND(!remaps.has(key));
|
|
PoolStringArray r = remaps[key];
|
|
PoolStringArray r = remaps[key];
|
|
ERR_FAIL_INDEX(idx, r.size());
|
|
ERR_FAIL_INDEX(idx, r.size());
|
|
- r.set(idx, path + ":" + langs[which]);
|
|
|
|
|
|
+ if (translation_locales_idxs_remap.size() > 0) {
|
|
|
|
+ r.set(idx, path + ":" + langs[translation_locales_idxs_remap[which]]);
|
|
|
|
+ } else {
|
|
|
|
+ r.set(idx, path + ":" + langs[which]);
|
|
|
|
+ }
|
|
remaps[key] = r;
|
|
remaps[key] = r;
|
|
|
|
|
|
updating_translations = true;
|
|
updating_translations = true;
|
|
@@ -1203,6 +1207,88 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p
|
|
undo_redo->commit_action();
|
|
undo_redo->commit_action();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void ProjectSettingsEditor::_translation_filter_option_changed() {
|
|
|
|
+
|
|
|
|
+ int sel_id = translation_locale_filter_mode->get_selected_id();
|
|
|
|
+ TreeItem *t = translation_filter->get_selected();
|
|
|
|
+ String locale = t->get_tooltip(0);
|
|
|
|
+ bool checked = t->is_checked(0);
|
|
|
|
+
|
|
|
|
+ Variant prev;
|
|
|
|
+ Array f_locales_all;
|
|
|
|
+
|
|
|
|
+ if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
|
|
|
|
+ f_locales_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
|
|
|
|
+ prev = f_locales_all;
|
|
|
|
+
|
|
|
|
+ if (f_locales_all.size() != 2) {
|
|
|
|
+ f_locales_all.clear();
|
|
|
|
+ f_locales_all.append(sel_id);
|
|
|
|
+ f_locales_all.append(Array());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ f_locales_all.append(sel_id);
|
|
|
|
+ f_locales_all.append(Array());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Array f_locales = f_locales_all[1];
|
|
|
|
+ int l_idx = f_locales.find(locale);
|
|
|
|
+
|
|
|
|
+ if (checked) {
|
|
|
|
+ if (l_idx == -1) {
|
|
|
|
+ f_locales.append(locale);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (l_idx != -1) {
|
|
|
|
+ f_locales.remove(l_idx);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ f_locales = f_locales.sort();
|
|
|
|
+
|
|
|
|
+ undo_redo->create_action(TTR("Changed Locale Filter"));
|
|
|
|
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/locale_filter", f_locales_all);
|
|
|
|
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/locale_filter", prev);
|
|
|
|
+ undo_redo->add_do_method(this, "_update_translations");
|
|
|
|
+ undo_redo->add_undo_method(this, "_update_translations");
|
|
|
|
+ undo_redo->add_do_method(this, "_settings_changed");
|
|
|
|
+ undo_redo->add_undo_method(this, "_settings_changed");
|
|
|
|
+ undo_redo->commit_action();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ProjectSettingsEditor::_translation_filter_mode_changed(int p_mode) {
|
|
|
|
+
|
|
|
|
+ int sel_id = translation_locale_filter_mode->get_selected_id();
|
|
|
|
+
|
|
|
|
+ Variant prev;
|
|
|
|
+ Array f_locales_all;
|
|
|
|
+
|
|
|
|
+ if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
|
|
|
|
+ f_locales_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
|
|
|
|
+ prev = f_locales_all;
|
|
|
|
+
|
|
|
|
+ if (f_locales_all.size() != 2) {
|
|
|
|
+ f_locales_all.clear();
|
|
|
|
+ f_locales_all.append(sel_id);
|
|
|
|
+ f_locales_all.append(Array());
|
|
|
|
+ } else {
|
|
|
|
+ f_locales_all[0] = sel_id;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ f_locales_all.append(sel_id);
|
|
|
|
+ f_locales_all.append(Array());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ undo_redo->create_action(TTR("Changed Locale Filter Mode"));
|
|
|
|
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/locale_filter", f_locales_all);
|
|
|
|
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/locale_filter", prev);
|
|
|
|
+ undo_redo->add_do_method(this, "_update_translations");
|
|
|
|
+ undo_redo->add_undo_method(this, "_update_translations");
|
|
|
|
+ undo_redo->add_do_method(this, "_settings_changed");
|
|
|
|
+ undo_redo->add_undo_method(this, "_settings_changed");
|
|
|
|
+ undo_redo->commit_action();
|
|
|
|
+}
|
|
|
|
+
|
|
void ProjectSettingsEditor::_update_translations() {
|
|
void ProjectSettingsEditor::_update_translations() {
|
|
|
|
|
|
//update translations
|
|
//update translations
|
|
@@ -1229,6 +1315,61 @@ void ProjectSettingsEditor::_update_translations() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Vector<String> langs = TranslationServer::get_all_locales();
|
|
|
|
+ Vector<String> names = TranslationServer::get_all_locale_names();
|
|
|
|
+
|
|
|
|
+ //update filter tab
|
|
|
|
+ Array l_filter_all;
|
|
|
|
+
|
|
|
|
+ bool is_arr_empty = true;
|
|
|
|
+ if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
|
|
|
|
+
|
|
|
|
+ l_filter_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
|
|
|
|
+
|
|
|
|
+ if (l_filter_all.size() == 2) {
|
|
|
|
+
|
|
|
|
+ translation_locale_filter_mode->select(l_filter_all[0]);
|
|
|
|
+ is_arr_empty = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (is_arr_empty) {
|
|
|
|
+
|
|
|
|
+ l_filter_all.append(0);
|
|
|
|
+ l_filter_all.append(Array());
|
|
|
|
+ translation_locale_filter_mode->select(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int filter_mode = l_filter_all[0];
|
|
|
|
+ Array l_filter = l_filter_all[1];
|
|
|
|
+
|
|
|
|
+ int s = names.size();
|
|
|
|
+ if (!translation_locales_list_created) {
|
|
|
|
+
|
|
|
|
+ translation_locales_list_created = true;
|
|
|
|
+ translation_filter->clear();
|
|
|
|
+ root = translation_filter->create_item(NULL);
|
|
|
|
+ translation_filter->set_hide_root(true);
|
|
|
|
+ translation_filter_treeitems.resize(s);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < s; i++) {
|
|
|
|
+ String n = names[i];
|
|
|
|
+ String l = langs[i];
|
|
|
|
+ TreeItem *t = translation_filter->create_item(root);
|
|
|
|
+ t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
|
|
|
+ t->set_text(0, n);
|
|
|
|
+ t->set_editable(0, true);
|
|
|
|
+ t->set_tooltip(0, l);
|
|
|
|
+ t->set_checked(0, l_filter.has(l));
|
|
|
|
+ translation_filter_treeitems[i] = t;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (int i = 0; i < s; i++) {
|
|
|
|
+
|
|
|
|
+ TreeItem *t = translation_filter_treeitems[i];
|
|
|
|
+ t->set_checked(0, l_filter.has(t->get_tooltip(0)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//update translation remaps
|
|
//update translation remaps
|
|
|
|
|
|
String remap_selected;
|
|
String remap_selected;
|
|
@@ -1244,13 +1385,30 @@ void ProjectSettingsEditor::_update_translations() {
|
|
translation_remap_options->set_hide_root(true);
|
|
translation_remap_options->set_hide_root(true);
|
|
translation_res_option_add_button->set_disabled(true);
|
|
translation_res_option_add_button->set_disabled(true);
|
|
|
|
|
|
- Vector<String> langs = TranslationServer::get_all_locales();
|
|
|
|
- Vector<String> names = TranslationServer::get_all_locale_names();
|
|
|
|
- String langnames;
|
|
|
|
|
|
+ translation_locales_idxs_remap.clear();
|
|
|
|
+ translation_locales_idxs_remap.resize(l_filter.size());
|
|
|
|
+ int fl_idx_count = translation_locales_idxs_remap.size();
|
|
|
|
+
|
|
|
|
+ String langnames = "";
|
|
|
|
+ int l_idx = 0;
|
|
for (int i = 0; i < names.size(); i++) {
|
|
for (int i = 0; i < names.size(); i++) {
|
|
- if (i > 0)
|
|
|
|
- langnames += ",";
|
|
|
|
- langnames += names[i];
|
|
|
|
|
|
+
|
|
|
|
+ if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && fl_idx_count != 0) {
|
|
|
|
+ if (l_filter.size() > 0) {
|
|
|
|
+
|
|
|
|
+ if (l_filter.find(langs[i]) != -1) {
|
|
|
|
+ if (langnames.length() > 0)
|
|
|
|
+ langnames += ",";
|
|
|
|
+ langnames += names[i];
|
|
|
|
+ translation_locales_idxs_remap[l_idx] = i;
|
|
|
|
+ l_idx++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (i > 0)
|
|
|
|
+ langnames += ",";
|
|
|
|
+ langnames += names[i];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
|
|
if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
|
|
@@ -1295,11 +1453,18 @@ void ProjectSettingsEditor::_update_translations() {
|
|
t2->set_editable(1, true);
|
|
t2->set_editable(1, true);
|
|
t2->set_metadata(1, path);
|
|
t2->set_metadata(1, path);
|
|
int idx = langs.find(locale);
|
|
int idx = langs.find(locale);
|
|
- print_line("find " + locale + " at " + itos(idx));
|
|
|
|
|
|
+ //print_line("find " + locale + " at " + itos(idx));
|
|
if (idx < 0)
|
|
if (idx < 0)
|
|
idx = 0;
|
|
idx = 0;
|
|
|
|
|
|
- t2->set_range(1, idx);
|
|
|
|
|
|
+ int f_idx = translation_locales_idxs_remap.find(idx);
|
|
|
|
+ if (f_idx != -1 && fl_idx_count > 0 && filter_mode == SHOW_ONLY_SELECTED_LOCALES) {
|
|
|
|
+
|
|
|
|
+ t2->set_range(1, f_idx);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ t2->set_range(1, idx);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1381,6 +1546,9 @@ void ProjectSettingsEditor::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettingsEditor::_translation_res_delete);
|
|
ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettingsEditor::_translation_res_delete);
|
|
ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettingsEditor::_translation_res_option_delete);
|
|
ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettingsEditor::_translation_res_option_delete);
|
|
|
|
|
|
|
|
+ ClassDB::bind_method(D_METHOD("_translation_filter_option_changed"), &ProjectSettingsEditor::_translation_filter_option_changed);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("_translation_filter_mode_changed"), &ProjectSettingsEditor::_translation_filter_mode_changed);
|
|
|
|
+
|
|
ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettingsEditor::_clear_search_box);
|
|
ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettingsEditor::_clear_search_box);
|
|
ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar);
|
|
ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar);
|
|
|
|
|
|
@@ -1601,6 +1769,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
|
translations->set_tab_align(TabContainer::ALIGN_LEFT);
|
|
translations->set_tab_align(TabContainer::ALIGN_LEFT);
|
|
translations->set_name(TTR("Localization"));
|
|
translations->set_name(TTR("Localization"));
|
|
tab_container->add_child(translations);
|
|
tab_container->add_child(translations);
|
|
|
|
+ //remap for properly select language in popup
|
|
|
|
+ translation_locales_idxs_remap = Vector<int>();
|
|
|
|
|
|
{
|
|
{
|
|
|
|
|
|
@@ -1683,6 +1853,29 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
|
translation_res_option_file_open->connect("file_selected", this, "_translation_res_option_add");
|
|
translation_res_option_file_open->connect("file_selected", this, "_translation_res_option_add");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ {
|
|
|
|
+ VBoxContainer *tvb = memnew(VBoxContainer);
|
|
|
|
+ translations->add_child(tvb);
|
|
|
|
+ tvb->set_name(TTR("Locales Filter"));
|
|
|
|
+ VBoxContainer *tmc = memnew(VBoxContainer);
|
|
|
|
+ tmc->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
+ tvb->add_child(tmc);
|
|
|
|
+
|
|
|
|
+ translation_locale_filter_mode = memnew(OptionButton);
|
|
|
|
+ translation_locale_filter_mode->add_item(TTR("Show all locales"), SHOW_ALL_LOCALES);
|
|
|
|
+ translation_locale_filter_mode->add_item(TTR("Show only selected locales"), SHOW_ONLY_SELECTED_LOCALES);
|
|
|
|
+ translation_locale_filter_mode->select(0);
|
|
|
|
+ tmc->add_margin_child(TTR("Filter mode:"), translation_locale_filter_mode);
|
|
|
|
+ translation_locale_filter_mode->connect("item_selected", this, "_translation_filter_mode_changed");
|
|
|
|
+
|
|
|
|
+ translation_filter = memnew(Tree);
|
|
|
|
+ translation_filter->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
+ translation_filter->set_columns(1);
|
|
|
|
+ tmc->add_child(memnew(Label(TTR("Locales:"))));
|
|
|
|
+ tmc->add_child(translation_filter);
|
|
|
|
+ translation_filter->connect("item_edited", this, "_translation_filter_option_changed");
|
|
|
|
+ }
|
|
|
|
+
|
|
{
|
|
{
|
|
autoload_settings = memnew(EditorAutoloadSettings);
|
|
autoload_settings = memnew(EditorAutoloadSettings);
|
|
autoload_settings->set_name(TTR("AutoLoad"));
|
|
autoload_settings->set_name(TTR("AutoLoad"));
|