wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src config.cpp


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth/src config.cpp
Date: Wed, 24 Nov 2004 19:26:43 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    04/11/25 00:20:53

Modified files:
        src            : config.cpp 

Log message:
        changes to WML for better i18n support

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.cpp.diff?tr1=1.113&tr2=1.114&r1=text&r2=text

Patches:
Index: wesnoth/src/config.cpp
diff -u wesnoth/src/config.cpp:1.113 wesnoth/src/config.cpp:1.114
--- wesnoth/src/config.cpp:1.113        Thu Nov 18 22:00:12 2004
+++ wesnoth/src/config.cpp      Thu Nov 25 00:20:53 2004
@@ -1,4 +1,4 @@
-/* $Id: config.cpp,v 1.113 2004/11/18 22:00:12 ydirson Exp $ */
+/* $Id: config.cpp,v 1.114 2004/11/25 00:20:53 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -566,10 +566,12 @@
 
        enum { ELEMENT_NAME, IN_ELEMENT, VARIABLE_NAME, VALUE }
        state = IN_ELEMENT;
-       std::string var;
+       std::string var;
+
+       std::vector<std::pair<std::string,bool> > stored_values;
        std::string value;
 
-       bool in_quotes = false, has_quotes = false, in_comment = false, 
escape_next = false, translatable = false;;
+       bool in_quotes = false, has_quotes = false, in_comment = false, 
escape_next = false, translatable = false, expecting_value = false;
 
        int line = 0;
 
@@ -722,7 +724,8 @@
                                if(in_quotes && c == '"' && (i+1) != data.end() 
&& *(i+1) == '"') {
                                        push_back(value, c);
                                        ++i; // skip the next double-quote
-                               } else if(c == '"') {
+                               } else if(c == '"') {
+                                       expecting_value = false;
                                        in_quotes = !in_quotes;
                                        has_quotes = true;
 
@@ -735,7 +738,26 @@
                                                        translatable = true;
                                                }
                                        }
-                               } else if(c == '\n' && !in_quotes) {
+                               } else if(c == '+' && has_quotes && !in_quotes) 
{
+                                       
stored_values.push_back(std::make_pair(value,translatable));
+                                       value = "";
+                                       translatable = false;
+                                       expecting_value = true;
+                               } else if(c == '\n' && !in_quotes && 
expecting_value) {
+                                       //do nothing...just ignore
+                               } else if(c == '\n' && !in_quotes) {
+
+                                       
stored_values.push_back(std::make_pair(value,translatable));
+                                       value = "";
+                                       
for(std::vector<std::pair<std::string,bool> >::const_iterator i = 
stored_values.begin(); i != stored_values.end(); ++i) {
+                                               if(i->second) {
+                                                       value += 
dsgettext(current_textdomain.c_str(),i->first.c_str());
+                                               } else {
+                                                       value += i->first;
+                                               }
+                                       }
+
+                                       stored_values.clear();
 
                                        //see if this is a CSV list=CSV list 
style assignment (e.g. x,y=5,8)
                                        std::vector<std::string> vars, values;
@@ -776,11 +798,6 @@
                                                                strip(value);
                                                        }
 
-                                                       if(translatable) {
-                                                               value = 
dsgettext(current_textdomain.c_str(),
-                                                                               
  value.c_str());
-                                                       }
-
                                                        if(n < vars.size()) {
                                                                
elements.top()->values[vars[n]] = value;
                                                        } else {
@@ -795,7 +812,8 @@
                                        has_quotes = false;
                                        escape_next = false;
                                        translatable = false;
-                               } else if(in_quotes || !has_quotes) {
+                               } else if(in_quotes || !has_quotes) {
+                                       expecting_value = false;
                                        push_back(value, c);
                                }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]