[Supertux-Commit] [tinygettext commit] r149 - in branches/tinygettext-portable: . src test

codesite-noreply at google.com codesite-noreply at google.com
Mon Feb 2 06:16:14 PST 2009


Author: grumbel
Date: Mon Feb  2 04:55:10 2009
New Revision: 149

Modified:
    branches/tinygettext-portable/README
    branches/tinygettext-portable/src/language.hpp
    branches/tinygettext-portable/test/tinygettext.cpp

Log:
Fixed DictionaryManager::get_languages(), proper compare was missing to  
make std::set work

Modified: branches/tinygettext-portable/README
==============================================================================
--- branches/tinygettext-portable/README	(original)
+++ branches/tinygettext-portable/README	Mon Feb  2 04:55:10 2009
@@ -7,4 +7,15 @@
  better suited for non-Unix systems and situations in which one wants
  to store or distrubite .po files seperatly from the software itself.

+
+
+Detecting the locale setting
+============================
+
+Different operating systems store the default locale in different
+places, a portable way to find it, is provided by FindLocale:
+
+ * http://icculus.org/~aspirin/findlocale/
+
+
  # EOF #

Modified: branches/tinygettext-portable/src/language.hpp
==============================================================================
--- branches/tinygettext-portable/src/language.hpp	(original)
+++ branches/tinygettext-portable/src/language.hpp	Mon Feb  2 04:55:10 2009
@@ -56,14 +56,20 @@

    /** Create an undefined Language object */
    Language();
-
+
    operator bool() const { return language_spec; }

    std::string get_language() const;
    std::string get_country()  const;
    std::string get_modifier()  const;
    std::string get_name()     const;
+
+  friend bool operator<(const Language& lhs, const Language& rhs);
  };
+
+inline bool operator<(const Language& lhs, const Language& rhs) {
+  return lhs.language_spec < rhs.language_spec;
+}
  
  } // namespace tinygettext


Modified: branches/tinygettext-portable/test/tinygettext.cpp
==============================================================================
--- branches/tinygettext-portable/test/tinygettext.cpp	(original)
+++ branches/tinygettext-portable/test/tinygettext.cpp	Mon Feb  2 04:55:10  
2009
@@ -33,6 +33,7 @@
    std::cout << "       " << argv[0] << " translate FILE MESSAGE_S  
MESSAGE_P NUM" << std::endl;
    std::cout << "       " << argv[0] << " directory DIRECTORY MESSAGE  
[LANG]" << std::endl;
    std::cout << "       " << argv[0] << " language LANGUAGE" << std::endl;
+  std::cout << "       " << argv[0] << " language-dir DIR" << std::endl;
  }

  void read_dictionary(const std::string& filename, Dictionary& dict)
@@ -54,7 +55,23 @@
  {
    try
      {
-      if (argc == 3 && strcmp(argv[1], "language") == 0)
+      if (argc == 3 && strcmp(argv[1], "language-dir") == 0)
+        {
+          DictionaryManager dictionary_manager;
+          dictionary_manager.add_directory(argv[2]);
+          const std::set<Language>& languages =  
dictionary_manager.get_languages();
+          std::cout << "Number of languages: " << languages.size() <<  
std::endl;
+          for (std::set<Language>::const_iterator i = languages.begin();  
i != languages.end(); ++i)
+            {
+              const Language& language = *i;
+              std::cout << "Name:      " << language.get_name()      <<  
std::endl
+                        << "Language:  " << language.get_language()  <<  
std::endl
+                        << "Country:   " << language.get_country()   <<  
std::endl
+                        << "Modifier:  " << language.get_modifier()  <<  
std::endl
+                        << std::endl;
+            }
+        }
+      else if (argc == 3 && strcmp(argv[1], "language") == 0)
          {
            Language language = Language::from_name(argv[2]);

@@ -63,8 +80,8 @@
                        << "Language:  " << language.get_language()  <<  
std::endl
                        << "Country:   " << language.get_country()   <<  
std::endl
                        << "Modifier:  " << language.get_modifier()  <<  
std::endl;
-            else
-              std::cout << "not found" << std::endl;
+          else
+            std::cout << "not found" << std::endl;
          }
        else if (argc == 4 && strcmp(argv[1], "translate") == 0)
          {


More information about the Supertux-Commit mailing list