- Fixed a few tranlsation issues in the code
- Updated French translation
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-10-31 07:58:21 +00:00
parent 41012eecde
commit 01c949f881
12 changed files with 279 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
#include "../include/Translate.h"
#include "../include/config.h"
#include "../include/Translate.h"
#include "../include/config.h"
#include <JGE.h>
#include <fstream>
#include <iostream>
@@ -23,14 +23,43 @@ int Translator::Add(string from, string to){
string Translator::translate(string value){
map<string,string>::iterator it = values.find(value);
if (it != values.end()) return it->second;
#if defined DEBUG_TRANSLATE
if (checkMisses){
map<string,int>::iterator it2 = dontCareValues.find(value);
if (it2 == dontCareValues.end())
missingValues[value] = 1;
}
#endif
return value;
}
Translator::~Translator(){
#if defined DEBUG_TRANSLATE
if (!checkMisses) return;
std::ofstream file("Res/lang/missing.txt");
char writer[4096];
if (file){
map<string,int>::iterator it;
for (it = missingValues.begin(); it!=missingValues.end(); it++){
sprintf(writer,"%s=\n", it->first.c_str());
file<<writer;
}
file.close();
}
#endif
}
Translator::Translator(){
#if defined DEBUG_TRANSLATE
checkMisses = 0;
#endif
std::ifstream file("Res/lang/_lang.txt");
std::string s;
if(file){
#if defined DEBUG_TRANSLATE
checkMisses = 1;
#endif
while(std::getline(file,s)){
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
@@ -42,10 +71,28 @@ Translator::Translator(){
}
file.close();
}
#if defined DEBUG_TRANSLATE
if (!checkMisses) return;
std::ifstream file2("Res/lang/dontcare.txt");
if(file2){
while(std::getline(file2,s)){
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
size_t found = s.find('=');
if (found != string::npos)
s = s.substr(0,found);
dontCareValues[s] = 1;
}
file2.close();
}
#endif
}
string _(string toTranslate){
Translator * t = Translator::GetInstance();
return t->translate(toTranslate);
}
string _(string toTranslate){
Translator * t = Translator::GetInstance();
return t->translate(toTranslate);
}