[Super-tux-commit] supertux/src level.cpp,1.97,1.98 lispreader.cpp,1.28,1.29 lispreader.h,1.14,1.15
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-07-08 10:11:33
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17490/src Modified Files: level.cpp lispreader.cpp lispreader.h worldmap.cpp Log Message: I18N: - Also check without country code. ie. Germany is the same for German and Austria. - Only check for translation when the code asks for. (translatable flag) Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.97 retrieving revision 1.98 diff -u -d -r1.97 -r1.98 --- level.cpp 7 Jul 2004 17:56:01 -0000 1.97 +++ level.cpp 8 Jul 2004 10:11:08 -0000 1.98 @@ -89,7 +89,7 @@ void Level::load_old_format(LispReader& reader) { - reader.read_string("name", name); + reader.read_string("name", name, true); reader.read_string("author", author); reader.read_int("time", time_left); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- worldmap.cpp 7 Jul 2004 17:56:01 -0000 1.88 +++ worldmap.cpp 8 Jul 2004 10:11:08 -0000 1.89 @@ -402,7 +402,7 @@ else if (strcmp(lisp_symbol(lisp_car(element)), "properties") == 0) { LispReader reader(lisp_cdr(element)); - reader.read_string("name", name); + reader.read_string("name", name, true); reader.read_string("music", music); } else if (strcmp(lisp_symbol(lisp_car(element)), "levels") == 0) @@ -425,7 +425,7 @@ level.west = true; reader.read_string("extro-filename", level.extro_filename); - reader.read_string("name", level.name); + reader.read_string("name", level.name, true); reader.read_int("x", level.x); reader.read_int("y", level.y); level.vertical_flip = false; @@ -475,7 +475,7 @@ if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) { LispReader reader(lisp_cdr(root_obj)); - reader.read_string("name", level.title); + reader.read_string("name", level.title, true); } lisp_free(root_obj); @@ -1067,7 +1067,7 @@ bool solved = false; LispReader level_reader(data); - level_reader.read_string("name", name); + level_reader.read_string("name", name, true); level_reader.read_bool("solved", solved); for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/lispreader.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- lispreader.cpp 7 Jul 2004 22:47:06 -0000 1.28 +++ lispreader.cpp 8 Jul 2004 10:11:08 -0000 1.29 @@ -1206,13 +1206,37 @@ } bool -LispReader::read_string (const char* name, std::string& str) +LispReader::read_string (const char* name, std::string& str, bool translatable) { - char str_[1024]; - sprintf(str_, "%s-%s", name, getenv("LANG")); - lisp_object_t* obj = search_for (str_); + lisp_object_t* obj; + if(translatable) + { + /* Internationalization support: check for the suffix: str + "-" + $LANG variable. + If not found, use the regular string. + So, translating a string in a Lisp file would result in something like: + (text "Hello World!") + (text-fr "Bonjour Monde!") + being fr the value of LANG (echo $LANG) for the language we want to translate to */ - if(!obj) + char str_[1024]; // check, for instance, for (title-fr_FR "Bonjour") + sprintf(str_, "%s-%s", name, getenv("LANG")); + + obj = search_for (str_); + + if(!obj) // check, for instance, for (title-fr "Bonjour") + { + char lang[3]; + strncpy(lang, getenv("LANG"), 2); + lang[2] = '\0'; + sprintf(str_, "%s-%s", name, lang); + + obj = search_for (str_); + } + + if(!obj) // check, for instance, for (title "Hello") + obj = search_for (name); + } + else obj = search_for (name); if (!obj) Index: lispreader.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/lispreader.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- lispreader.h 15 Jun 2004 12:18:59 -0000 1.14 +++ lispreader.h 8 Jul 2004 10:11:08 -0000 1.15 @@ -187,7 +187,7 @@ bool read_int_vector(const char* name, std::vector<unsigned int>& vec); bool read_char_vector(const char* name, std::vector<char>& vec); bool read_string_vector(const char* name, std::vector<std::string>& vec); - bool read_string(const char* name, std::string& str); + bool read_string(const char* name, std::string& str, bool translatable = false); bool read_int(const char* name, int& i); bool read_float(const char* name, float& f); bool read_bool(const char* name, bool& b); |