put ICONV_CONST back in, you have to rerun autogen.sh and configure if you lack it
[supertux.git] / src / tinygettext / tinygettext.cpp
index dd73e80..f151e64 100644 (file)
@@ -49,7 +49,7 @@ std::string convert(const std::string& text,
   strcpy(in_orig, text.c_str());
 
   char* out = out_orig;
-  char* in  = in_orig;
+  ICONV_CONST char* in  = in_orig;
   size_t out_len_temp = out_len; // iconv is counting down the bytes it has
                                  // written from this...
 
@@ -433,6 +433,20 @@ Dictionary::translate(const std::string& msgid)
       return msgid;
     }
 }
+
+const char*
+Dictionary::translate(const char* msgid)
+{
+  Entries::iterator i = entries.find(msgid);
+  if(i == entries.end() || i->second.empty()) {
+#ifdef TRANSLATION_DBEUG
+    std::cout << "Error: Couldn't translate: " << msgid << std::endl;
+#endif                                                                     
+    return msgid;
+  }
+
+  return i->second.c_str();
+}
   
 void
 Dictionary::add_translation(const std::string& msgid, const std::string& ,
@@ -477,6 +491,13 @@ public:
   {
     state = WANT_MSGID;
     line_num = 0;
+    char c = in.get();
+    if(c == (char) 0xef) { // skip UTF-8 intro that some texteditors produce
+      in.get();
+      in.get();
+    } else {
+      in.unget();
+    }
     tokenize_po(in);
   }