CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <[EMAIL PROTECTED]>   05/04/17 18:53:11

Modified files:
        .              : changelog 
        data           : game.cfg 
        src            : game.cpp language.cpp language.hpp tstring.cpp 
                         tstring.hpp 
        src/editor     : editor_main.cpp 

Log message:
        Made user-campaigns translatable. Added a new top-level WML tag, 
[textdomain],
        which can contain 2 variables:
        
        * name contains the textdomain's name
        * path contains the binary path of the textdomain. Uses the game's 
default
        binary path for translations if not defined or empty.
        
        This element must be present for each textdomain available

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/changelog.diff?tr1=1.596&tr2=1.597&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/game.cfg.diff?tr1=1.150&tr2=1.151&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.230&tr2=1.231&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/language.cpp.diff?tr1=1.84&tr2=1.85&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/language.hpp.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tstring.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tstring.hpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor_main.cpp.diff?tr1=1.32&tr2=1.33&r1=text&r2=text

Patches:
Index: wesnoth/changelog
diff -u wesnoth/changelog:1.596 wesnoth/changelog:1.597
--- wesnoth/changelog:1.596     Sun Apr 17 15:40:33 2005
+++ wesnoth/changelog   Sun Apr 17 18:53:09 2005
@@ -35,6 +35,7 @@
  * fixed some OoS errors when chatting while a fight is taking place
  * fixed the spurious "statistics verification failed" messages
  * fixed bug #12611: modifying villages with [terrain] interacting badly with 
capturing them.
+ * fixed user-campaigns not being translatable anymore
  
 Version 0.9.0:
  * user interface improvements:
Index: wesnoth/data/game.cfg
diff -u wesnoth/data/game.cfg:1.150 wesnoth/data/game.cfg:1.151
--- wesnoth/data/game.cfg:1.150 Tue Apr  5 00:15:10 2005
+++ wesnoth/data/game.cfg       Sun Apr 17 18:53:10 2005
@@ -87,6 +87,28 @@
        
 [/game_config]
 
+[textdomain]
+       name="wesnoth"
+[/textdomain]
+[textdomain]
+       name="wesnoth-lib"
+[/textdomain]
+[textdomain]
+       name="wesnoth-editor"
+[/textdomain]
+[textdomain]
+       name="wesnoth-httt"
+[/textdomain]
+[textdomain]
+       name="wesnoth-ei"
+[/textdomain]
+[textdomain]
+       name="wesnoth-trow"
+[/textdomain]
+[textdomain]
+       name="wesnoth-sotbe"
+[/textdomain]
+
 #ifdef APPLE
        [hotkey]
        command=preferences
Index: wesnoth/src/editor/editor_main.cpp
diff -u wesnoth/src/editor/editor_main.cpp:1.32 
wesnoth/src/editor/editor_main.cpp:1.33
--- wesnoth/src/editor/editor_main.cpp:1.32     Sat Apr  9 14:49:05 2005
+++ wesnoth/src/editor/editor_main.cpp  Sun Apr 17 18:53:11 2005
@@ -237,10 +237,11 @@
                std::cerr << "Error when reading game config: '" << e.message 
<< "'" << std::endl;
        }
        font::load_font_config();
+       ::init_textdomains(cfg);
 
        if(mapdata.empty()) {
                for(int i = 0; i != 20; ++i) {
-                       mapdata = mapdata + "gggggggggggggggggggg\n";
+                       mapdata += "gggggggggggggggggggg\n";
                }
        }
        
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.230 wesnoth/src/game.cpp:1.231
--- wesnoth/src/game.cpp:1.230  Sun Apr 17 13:49:00 2005
+++ wesnoth/src/game.cpp        Sun Apr 17 18:53:10 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.230 2005/04/17 13:49:00 gruikya Exp $ */
+/* $Id: game.cpp,v 1.231 2005/04/17 18:53:10 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <[EMAIL PROTECTED]>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -516,8 +516,8 @@
        game_config::load_config(game_config_.child("game_config"));
 
        hotkey::load_hotkeys(game_config_);
-
        paths_manager_.set_paths(game_config_);
+       ::init_textdomains(game_config_);
 
        return true;
 }
Index: wesnoth/src/language.cpp
diff -u wesnoth/src/language.cpp:1.84 wesnoth/src/language.cpp:1.85
--- wesnoth/src/language.cpp:1.84       Wed Apr 13 21:26:18 2005
+++ wesnoth/src/language.cpp    Sun Apr 17 18:53:10 2005
@@ -1,4 +1,4 @@
-/* $Id: language.cpp,v 1.84 2005/04/13 21:26:18 ydirson Exp $ */
+/* $Id: language.cpp,v 1.85 2005/04/17 18:53:10 gruikya Exp $ */
 /* vim:set encoding=utf-8: */
 /*
    Copyright (C) 2003 by David White <[EMAIL PROTECTED]>
@@ -219,3 +219,20 @@
        return known_languages[0];
 }
 
+void init_textdomains(const config& cfg)
+{
+       config::const_child_itors t = cfg.child_range("textdomain");
+
+       for(;t.first != t.second; ++t.first) {
+               const std::string name = (**t.first)["name"];
+               const std::string path = (**t.first)["path"];
+
+               if(path.empty()) {
+                       t_string::add_textdomain(name, get_intl_dir());
+               } else {
+                       const std::string& location = 
get_binary_file_location(path, ".");
+                       t_string::add_textdomain(name, location);
+               }
+       }
+}
+
Index: wesnoth/src/language.hpp
diff -u wesnoth/src/language.hpp:1.34 wesnoth/src/language.hpp:1.35
--- wesnoth/src/language.hpp:1.34       Sun Mar 27 23:06:17 2005
+++ wesnoth/src/language.hpp    Sun Apr 17 18:53:10 2005
@@ -1,4 +1,4 @@
-/* $Id: language.hpp,v 1.34 2005/03/27 23:06:17 gruikya Exp $ */
+/* $Id: language.hpp,v 1.35 2005/04/17 18:53:10 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <[EMAIL PROTECTED]>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -21,6 +21,7 @@
 //this module controls internationalization.
 
 class t_string;
+class config;
 
 struct language_def
 {
@@ -62,4 +63,7 @@
 //function which attempts to query and return the locale on the system
 const language_def& get_locale();
 
+/** Initializes the list of textdomains from a configuration object */
+void init_textdomains(const config& cfg);
+
 #endif
Index: wesnoth/src/tstring.cpp
diff -u wesnoth/src/tstring.cpp:1.5 wesnoth/src/tstring.cpp:1.6
--- wesnoth/src/tstring.cpp:1.5 Sat Apr  9 17:36:07 2005
+++ wesnoth/src/tstring.cpp     Sun Apr 17 18:53:10 2005
@@ -1,4 +1,4 @@
-/* $Id: tstring.cpp,v 1.5 2005/04/09 17:36:07 silene Exp $ */
+/* $Id: tstring.cpp,v 1.6 2005/04/17 18:53:10 gruikya Exp $ */
 /*
    Copyright (C) 2004 by Philippe Plantier <[EMAIL PROTECTED]>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -19,6 +19,7 @@
 #include "filesystem.hpp"
 #include "log.hpp"
 
+#define LOG_CF lg::info(lg::config)
 #define ERR_CF lg::err(lg::config)
 
 namespace {
@@ -194,10 +195,6 @@
                textdomain_to_id[textdomain] = id_to_textdomain.size();
                id = id_to_textdomain.size();
                id_to_textdomain.push_back(textdomain);
-
-               // Register and bind this textdomain
-               bindtextdomain(textdomain.c_str(), get_intl_dir().c_str());
-               bind_textdomain_codeset(textdomain.c_str(), "UTF-8");
        } else {
                id = idi->second;
        }
@@ -483,6 +480,15 @@
        return value_;
 }
 
+void t_string::add_textdomain(const std::string& name, const std::string& path)
+{
+       LOG_CF << "Binding textdomain " << name << " to path " << path << "\n";
+
+       // Register and (re-)bind this textdomain
+       bindtextdomain(name.c_str(), path.c_str());
+       bind_textdomain_codeset(name.c_str(), "UTF-8");
+}
+
 std::ostream& operator<<(std::ostream& stream, const t_string& string)
 {
        stream << string.str();
Index: wesnoth/src/tstring.hpp
diff -u wesnoth/src/tstring.hpp:1.4 wesnoth/src/tstring.hpp:1.5
--- wesnoth/src/tstring.hpp:1.4 Thu Apr  7 21:16:50 2005
+++ wesnoth/src/tstring.hpp     Sun Apr 17 18:53:10 2005
@@ -1,4 +1,4 @@
-/* $Id: tstring.hpp,v 1.4 2005/04/07 21:16:50 gruikya Exp $ */
+/* $Id: tstring.hpp,v 1.5 2005/04/17 18:53:10 gruikya Exp $ */
 /*
    Copyright (C) 2004 by Philippe Plantier <[EMAIL PROTECTED]>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -80,6 +80,7 @@
        const char* c_str() const;
        const std::string& value() const;
 
+       static void add_textdomain(const std::string& name, const std::string& 
path);
 private:
        bool translatable_;
        std::string value_;


Reply via email to