summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/editor_settings.cpp82
-rw-r--r--tools/editor/editor_settings.h5
2 files changed, 85 insertions, 2 deletions
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 05c4f74b0d..0b7e389773 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -41,6 +41,10 @@
#include "io/config_file.h"
#include "editor_node.h"
#include "globals.h"
+#include "translations.h"
+#include "io/file_access_memory.h"
+#include "io/translation_loader_po.h"
+#include "io/compression.h"
Ref<EditorSettings> EditorSettings::singleton=NULL;
@@ -284,6 +288,7 @@ void EditorSettings::create() {
print_line("EditorSettings: Load OK!");
}
+ singleton->setup_language();
singleton->setup_network();
singleton->load_favorites();
singleton->list_text_editor_themes();
@@ -309,10 +314,12 @@ void EditorSettings::create() {
singleton = Ref<EditorSettings>( memnew( EditorSettings ) );
singleton->config_file_path=config_file_path;
singleton->settings_path=config_path+"/"+config_dir;
- singleton->_load_defaults(extra_config);
+ singleton->_load_defaults(extra_config);
+ singleton->setup_language();
singleton->setup_network();
singleton->list_text_editor_themes();
+
}
String EditorSettings::get_settings_path() const {
@@ -322,6 +329,23 @@ String EditorSettings::get_settings_path() const {
+void EditorSettings::setup_language() {
+
+ String lang = get("global/editor_language");
+ print_line("LANG IS "+lang);
+ if (lang=="en")
+ return; //none to do
+
+ for(int i=0;i<translations.size();i++) {
+ print_line("TESTING "+translations[i]->get_locale());
+ if (translations[i]->get_locale()==lang) {
+ print_line("ok translation");
+ TranslationServer::get_singleton()->set_tool_translation(translations[i]);
+ break;
+ }
+ }
+}
+
void EditorSettings::setup_network() {
List<IP_Address> local_ip;
@@ -389,6 +413,36 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_THREAD_SAFE_METHOD_
+
+ {
+ String lang_hint="en";
+ String host_lang = OS::get_singleton()->get_locale();
+
+ String best;
+
+ for(int i=0;i<translations.size();i++) {
+ String locale = translations[i]->get_locale();
+ lang_hint+=",";
+ lang_hint+=locale;
+
+ if (host_lang==locale) {
+ best=locale;
+ }
+
+ if (best==String() && host_lang.begins_with(locale)) {
+ best=locale;
+ }
+ }
+
+ if (best==String()) {
+ best="en";
+ }
+
+ set("global/editor_language",best);
+ hints["global/editor_language"]=PropertyInfo(Variant::STRING,"global/editor_language",PROPERTY_HINT_ENUM,lang_hint,PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
+ }
+
+ set("global/show_script_in_scene_tabs",false);
set("global/font","");
hints["global/font"]=PropertyInfo(Variant::STRING,"global/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt");
set("global/autoscan_project_path","");
@@ -399,6 +453,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["global/default_project_export_path"]=PropertyInfo(Variant::STRING,"global/default_project_export_path",PROPERTY_HINT_GLOBAL_DIR);
set("global/show_script_in_scene_tabs",false);
+
set("text_editor/color_theme","Default");
hints["text_editor/color_theme"]=PropertyInfo(Variant::STRING,"text_editor/color_theme",PROPERTY_HINT_ENUM,"Default");
@@ -821,7 +876,32 @@ EditorSettings::EditorSettings() {
//singleton=this;
last_order=0;
+
+ EditorTranslationList *etl=_editor_translations;
+
+ while(etl->data) {
+
+ Vector<uint8_t> data;
+ data.resize(etl->uncomp_size);
+ Compression::decompress(data.ptr(),etl->uncomp_size,etl->data,etl->comp_size,Compression::MODE_DEFLATE);
+
+ FileAccessMemory *fa = memnew (FileAccessMemory);
+ fa->open_custom(data.ptr(),data.size());
+
+ Ref<Translation> tr = TranslationLoaderPO::load_translation(fa,NULL,"translation_"+String(etl->lang));
+
+ if (tr.is_valid()) {
+ tr->set_locale(etl->lang);
+ translations.push_back(tr);
+ }
+
+ etl++;
+
+ }
+
_load_defaults();
+
+
}
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index afd3232752..879c97c349 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -34,7 +34,7 @@
#include "resource.h"
#include "os/thread_safe.h"
#include "core/io/config_file.h"
-
+#include "translation.h"
class EditorPlugin;
class EditorSettings : public Resource {
@@ -93,6 +93,8 @@ private:
Vector<String> favorite_dirs;
Vector<String> recent_dirs;
+ Vector<Ref<Translation> > translations;
+
protected:
static void _bind_methods();
@@ -111,6 +113,7 @@ public:
String get_project_settings_path() const;
+ void setup_language();
void setup_network();
void raise_order(const String& p_name);