summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-05-27 19:58:28 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-05-27 19:58:28 -0300
commitbccdc11ddec9dc8690f2686c296eb81f424e56f9 (patch)
treedd7d45670652cd85b82c0e708fc1ea81c669fa88 /core/io
parent8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da (diff)
Added translation support to Godot
included is a French translation!
Diffstat (limited to 'core/io')
-rw-r--r--core/io/file_access_memory.cpp2
-rw-r--r--core/io/translation_loader_po.cpp25
-rw-r--r--core/io/translation_loader_po.h4
3 files changed, 22 insertions, 9 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;