gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/System.cpp server/...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/asobj/System.cpp server/...
Date: Wed, 30 Jan 2008 09:41:50 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/01/30 09:41:50

Modified files:
        .              : ChangeLog 
        server/asobj   : System.cpp 
        server/vm      : VM.cpp 

Log message:
                * server/vm/VM.cpp: let System.cpp decide what to do with the 
system
                  language string.
                * server/asobj/System.cpp: restrict System.capabilites.language 
codes
                  to the 20 officially specified. This is compatible with 
scripts
                  that rely on there only being twenty. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5523&r2=1.5524
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/System.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.cpp?cvsroot=gnash&r1=1.31&r2=1.32

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5523
retrieving revision 1.5524
diff -u -b -r1.5523 -r1.5524
--- ChangeLog   30 Jan 2008 06:10:09 -0000      1.5523
+++ ChangeLog   30 Jan 2008 09:41:49 -0000      1.5524
@@ -1,3 +1,11 @@
+2008-01-30 Benjamin Wolsey <address@hidden>
+
+       * server/vm/VM.cpp: let System.cpp decide what to do with the system
+         language string.
+       * server/asobj/System.cpp: restrict System.capabilites.language codes
+         to the 20 officially specified. This is compatible with scripts
+         that rely on there only being twenty. 
+
 2008-01-29 Bastiaan Jacques <address@hidden>
 
        * server/asobj/NetStreamGst.{cpp,h}: Warn if decodebin can't find a

Index: server/asobj/System.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/System.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- server/asobj/System.cpp     21 Jan 2008 20:55:58 -0000      1.21
+++ server/asobj/System.cpp     30 Jan 2008 09:41:50 -0000      1.22
@@ -33,6 +33,8 @@
 
 namespace gnash {
 
+std::string& systemLanguage();
+
 static as_value system_security_allowdomain(const fn_call& fn);
 static as_value system_security_allowinsecuredomain(const fn_call& fn);
 static as_value system_security_loadpolicyfile(const fn_call& fn);
@@ -79,12 +81,7 @@
        const std::string manufacturer = rcfile.getFlashSystemManufacturer();
 
        /* Human Interface */
-       
-       // Two-letter language code ('en', 'de') corresponding to ISO 639-1
-       // TODO: Chinese should be either zh-CN or zh-TW
-       // TODO: Are there more than the 20 officially documented? 
-       // TODO: Other / unknown should return 'xu'. 
-       const std::string language = VM::get().getSystemLanguage();
+       const std::string language = systemLanguage();
 
        /* Media */
                
@@ -209,4 +206,52 @@
        global.init_member("System", obj.get());
 }
 
+std::string& systemLanguage()
+{
+       // Two-letter language code ('en', 'de') corresponding to ISO 639-1
+       // Chinese can be either zh-CN or zh-TW. English used to have a 
+       // country (GB, US) qualifier, but that was dropped in version 7 of the 
player.
+       // This method relies on getting a POSIX-style language code of the form
+       // "zh_TW.utf8", "zh_CN" or "it" from the VM.
+       // It is obviously very easy to extend support to all language codes, 
but
+       // some scripts rely on there being only 20 possible languages. It could
+       // be a run time option if it's important enough to care.
+
+       static std::string lang = VM::get().getSystemLanguage();
+       
+       const char* languages[] = {"en", "fr", "ko", "ja", "sv",
+                               "de", "es", "it", "zh", "pt",
+                               "pl", "hu", "cs", "tr", "fi",
+                               "da", "nl", "no", "ru"};
+       
+       const unsigned int size = sizeof (languages) / sizeof (*languages);
+       
+       if (std::find(languages, languages + size, lang.substr(0,2)) != 
languages + size)
+       {
+               if (lang.substr(0,2) == "zh")
+               {
+                       // Chinese is the only language since the pp version 7
+                       // to need an additional qualifier.
+                       if (lang.substr(2, 3) == "_TW") lang = "zh-TW";
+                       else if (lang.substr(2, 3) == "_CN") lang = "zh-CN";
+                       else lang = "xu";
+               }
+               else
+               {
+                       // All other matching cases: retain just the first
+                       // two characters.
+                       lang.erase(2);
+               }
+       }
+       else
+       {
+               // Unknown language. We also return this if
+               // getSystemLanguage() returns something unexpected. 
+               lang = "xu";
+       }
+
+       return lang;
+
+}
+
 } // end of gnash namespace

Index: server/vm/VM.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/VM.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/vm/VM.cpp    21 Jan 2008 20:56:04 -0000      1.31
+++ server/vm/VM.cpp    30 Jan 2008 09:41:50 -0000      1.32
@@ -16,7 +16,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: VM.cpp,v 1.31 2008/01/21 20:56:04 rsavoye Exp $ */
+/* $Id: VM.cpp,v 1.32 2008/01/30 09:41:50 bwy Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "gnashconfig.h"
@@ -174,35 +174,26 @@
 const std::string
 VM::getSystemLanguage()
 {
-       std::string lang;
+
        char *loc;
        
        // Try various environment variables. These should
        // be in the standard form "de", "de_DE" or "de_DE.utf8"
-       // We'll return the first two characters anyway.
        // This should work on most UNIX-like systems.
+       // Callers should work out what to do with it.
        // TODO: Other OSs.
-       if ((loc = getenv("LANG")))
-       {
-               lang = loc;
-       }
-       else if ((loc = getenv("LANGUAGE")))
+       if ((loc = getenv("LANG")) ||
+               (loc = getenv("LANGUAGE")) ||
+               (loc = getenv("LC_MESSAGES"))
+               )
        {
-               lang = loc;
-       }
-       else if ((loc = getenv("LC_MESSAGES")))
-       {
-               lang = loc;
+               std::string lang = loc;
+               return lang;
        }
        
-       if (lang.length() >= 2)
-       {
-               return lang.substr(0,2);
-       }
        else
        {
-               // TODO: what should be returned if we fail to
-               // find a language string?
+               // No string found
                return "";
        }
 }




reply via email to

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