diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-05-27 19:58:28 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-05-27 19:58:28 -0300 |
commit | bccdc11ddec9dc8690f2686c296eb81f424e56f9 (patch) | |
tree | dd7d45670652cd85b82c0e708fc1ea81c669fa88 /core | |
parent | 8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da (diff) |
Added translation support to Godot
included is a French translation!
Diffstat (limited to 'core')
-rw-r--r-- | core/io/file_access_memory.cpp | 2 | ||||
-rw-r--r-- | core/io/translation_loader_po.cpp | 25 | ||||
-rw-r--r-- | core/io/translation_loader_po.h | 4 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | core/translation.cpp | 6 |
5 files changed, 27 insertions, 11 deletions
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 2cc52a9e2d..7db3499505 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -135,7 +135,7 @@ size_t FileAccessMemory::get_len() const { bool FileAccessMemory::eof_reached() const { - return pos >= length; + return pos > length; } uint8_t FileAccessMemory::get_8() const { diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index fe101a8676..4ddb276a27 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -30,13 +30,8 @@ #include "os/file_access.h" #include "translation.h" -RES TranslationLoaderPO::load(const String &p_path, const String& p_original_path, Error *r_error) { - if (r_error) - *r_error=ERR_CANT_OPEN; - - FileAccess *f=FileAccess::open(p_path,FileAccess::READ); - ERR_FAIL_COND_V(!f,RES()); +RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const String &p_path) { String l = f->get_line(); @@ -52,6 +47,8 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat String msg_id; String msg_str; String config; + int msg_line=0; + if (r_error) *r_error=ERR_FILE_CORRUPT; @@ -87,7 +84,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat if (status==STATUS_READING_ID) { memdelete(f); - ERR_EXPLAIN(p_path+":"+itos(line)+" nexpected 'msgid', was expecting 'msgstr' while parsing: "); + ERR_EXPLAIN(p_path+":"+itos(line)+" Unexpected 'msgid', was expecting 'msgstr' while parsing: "); ERR_FAIL_V(RES()); } @@ -100,6 +97,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat status=STATUS_READING_ID; msg_id=""; msg_str=""; + msg_line=line; } if (l.begins_with("msgstr")) { @@ -113,6 +111,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat l=l.substr(6,l.length()).strip_edges(); status=STATUS_READING_STRING; + msg_line=line; } if (l=="" || l.begins_with("#")) { @@ -183,6 +182,18 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat *r_error=OK; return translation; +} + +RES TranslationLoaderPO::load(const String &p_path, const String& p_original_path, Error *r_error) { + + if (r_error) + *r_error=ERR_CANT_OPEN; + + FileAccess *f=FileAccess::open(p_path,FileAccess::READ); + ERR_FAIL_COND_V(!f,RES()); + + + return load_translation(f,r_error); } diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index a569674d80..b0c4e42682 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -30,10 +30,12 @@ #define TRANSLATION_LOADER_PO_H #include "io/resource_loader.h" - +#include "translation.h" +#include "os/file_access.h" class TranslationLoaderPO : public ResourceFormatLoader { public: + static RES load_translation(FileAccess *f, Error *r_error,const String& p_path=String()); virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String& p_type) const; diff --git a/core/object.h b/core/object.h index 4ed78d3226..f4a2472e88 100644 --- a/core/object.h +++ b/core/object.h @@ -85,6 +85,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_STORE_IF_NONZERO=512, //only store if nonzero PROPERTY_USAGE_STORE_IF_NONONE=1024, //only store if false PROPERTY_USAGE_NO_INSTANCE_STATE=2048, + PROPERTY_USAGE_RESTART_IF_CHANGED=4096, PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED, diff --git a/core/translation.cpp b/core/translation.cpp index 85e207e08d..ee0ef2ea09 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -672,9 +672,11 @@ void TranslationServer::set_tool_translation(const Ref<Translation>& p_translati StringName TranslationServer::tool_translate(const StringName& p_message) const { if (tool_translation.is_valid()) { - StringName r = tool_translation->tr(p_message); - if (r) + StringName r = tool_translation->get_message(p_message); + + if (r) { return r; + } } return p_message; |