summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2021-04-22 15:08:59 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2021-04-22 16:56:53 +0300
commitb56241f22f96826ef9ef38cf7e4312b899f8e241 (patch)
treed12402a7b6881fe6f1f8c33228d5b1054c7942f0 /editor
parent77a876c6e1c9eb60abbd9ad6f6ba6d9bc0af14e1 (diff)
ICU: Update to version 69.1, improve ICU data export process.
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_export.cpp28
-rw-r--r--editor/localization_editor.cpp71
-rw-r--r--editor/localization_editor.h7
3 files changed, 21 insertions, 85 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index a5ebfbfb8a..a368a9618e 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1051,14 +1051,28 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
}
- // Store text server data if exists.
+ // Store text server data if it is supported.
if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
- String ts_data = "res://" + TS->get_support_data_filename();
- if (FileAccess::exists(ts_data)) {
- Vector<uint8_t> array = FileAccess::get_file_as_array(ts_data);
- err = p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key);
- if (err != OK) {
- return err;
+ bool use_data = ProjectSettings::get_singleton()->get("internationalization/locale/include_text_server_data");
+ if (use_data) {
+ // Try using user provided data file.
+ String ts_data = "res://" + TS->get_support_data_filename();
+ if (FileAccess::exists(ts_data)) {
+ Vector<uint8_t> array = FileAccess::get_file_as_array(ts_data);
+ err = p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key);
+ if (err != OK) {
+ return err;
+ }
+ } else {
+ // Use default text server data.
+ String icu_data_file = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_icu_data");
+ TS->save_support_data(icu_data_file);
+ Vector<uint8_t> array = FileAccess::get_file_as_array(icu_data_file);
+ err = p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key);
+ DirAccess::remove_file_or_error(icu_data_file);
+ if (err != OK) {
+ return err;
+ }
}
}
}
diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp
index 0e68af06f0..161f1dde0d 100644
--- a/editor/localization_editor.cpp
+++ b/editor/localization_editor.cpp
@@ -37,24 +37,6 @@
#include "scene/gui/control.h"
void LocalizationEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_TEXT_SERVER_CHANGED) {
- ts_name->set_text(TTR("Text server: ") + TS->get_name());
-
- FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
- if (file_check->file_exists("res://" + TS->get_support_data_filename())) {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Installed"));
- ts_install->set_disabled(true);
- } else {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Not installed"));
- ts_install->set_disabled(false);
- }
- } else {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Not supported"));
- ts_install->set_disabled(false);
- }
- ts_data_info->set_text(TTR("Info: ") + TS->get_support_data_info());
- }
if (p_what == NOTIFICATION_ENTER_TREE) {
translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete));
translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete));
@@ -649,26 +631,6 @@ void LocalizationEditor::update_translations() {
updating_translations = false;
}
-void LocalizationEditor::_install_ts_data() {
- if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
- TS->save_support_data("res://" + TS->get_support_data_filename());
- }
-
- FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
- if (file_check->file_exists("res://" + TS->get_support_data_filename())) {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Installed"));
- ts_install->set_disabled(true);
- } else {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Not installed"));
- ts_install->set_disabled(false);
- }
- } else {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Not supported"));
- ts_install->set_disabled(false);
- }
-}
-
void LocalizationEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("update_translations"), &LocalizationEditor::update_translations);
@@ -838,37 +800,4 @@ LocalizationEditor::LocalizationEditor() {
pot_file_open_dialog->connect("files_selected", callable_mp(this, &LocalizationEditor::_pot_add));
add_child(pot_file_open_dialog);
}
-
- {
- VBoxContainer *tvb = memnew(VBoxContainer);
- tvb->set_name(TTR("Text Server Data"));
- translations->add_child(tvb);
-
- ts_name = memnew(Label(TTR("Text server: ") + TS->get_name()));
- tvb->add_child(ts_name);
-
- ts_data_status = memnew(Label(TTR("Support data: ")));
- tvb->add_child(ts_data_status);
-
- ts_data_info = memnew(Label(TTR("Info: ") + TS->get_support_data_info()));
- tvb->add_child(ts_data_info);
-
- ts_install = memnew(Button(TTR("Install support data...")));
- ts_install->connect("pressed", callable_mp(this, &LocalizationEditor::_install_ts_data));
- tvb->add_child(ts_install);
-
- FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
- if (file_check->file_exists("res://" + TS->get_support_data_filename())) {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Installed"));
- ts_install->set_disabled(true);
- } else {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Not installed"));
- ts_install->set_disabled(false);
- }
- } else {
- ts_data_status->set_text(TTR("Support data: ") + TTR("Not supported"));
- ts_install->set_disabled(false);
- }
- }
}
diff --git a/editor/localization_editor.h b/editor/localization_editor.h
index 6e0d7ce61f..23cea06fbe 100644
--- a/editor/localization_editor.h
+++ b/editor/localization_editor.h
@@ -58,11 +58,6 @@ class LocalizationEditor : public VBoxContainer {
Vector<TreeItem *> translation_filter_treeitems;
Vector<int> translation_locales_idxs_remap;
- Label *ts_name;
- Label *ts_data_status;
- Label *ts_data_info;
- Button *ts_install;
-
Tree *translation_pot_list;
EditorFileDialog *pot_file_open_dialog;
EditorFileDialog *pot_generate_dialog;
@@ -94,8 +89,6 @@ class LocalizationEditor : public VBoxContainer {
void _pot_generate(const String &p_file);
void _update_pot_file_extensions();
- void _install_ts_data();
-
protected:
void _notification(int p_what);
static void _bind_methods();