[Scummvm-cvs-logs] SF.net SVN: scummvm:[49876] scummvm/trunk/common/translation.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Jun 15 19:47:24 CEST 2010


Revision: 49876
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49876&view=rev
Author:   lordhoto
Date:     2010-06-15 17:47:23 +0000 (Tue, 15 Jun 2010)

Log Message:
-----------
Strip out charset information from the system locale again (like it was done before r49871).

Unlike with the old code, we know allow for locales
with a different size than 5 though.

Modified Paths:
--------------
    scummvm/trunk/common/translation.cpp

Modified: scummvm/trunk/common/translation.cpp
===================================================================
--- scummvm/trunk/common/translation.cpp	2010-06-15 17:47:04 UTC (rev 49875)
+++ scummvm/trunk/common/translation.cpp	2010-06-15 17:47:23 UTC (rev 49876)
@@ -52,10 +52,28 @@
 	const char *locale = setlocale(LC_ALL, "");
 
 	// Detect the language from the locale
-	if (!locale)
+	if (!locale) {
 		_syslang = "C";
-	else
-		_syslang = locale;
+	} else {
+		int length = 0;
+
+		// Strip out additional information, like
+		// ".UTF-8" or the like. We do this, since
+		// our translation languages are usually
+		// specified without any charset information.
+		for (int i = 0; locale[i]; ++i) {
+			// TODO: Check whether "@" should really be checked
+			// here.
+			if (locale[i] == '.' || locale[i] == ' ' || locale[i] == '@') {
+				length = i;
+				break;
+			}
+
+			length = i;
+		}
+
+		_syslang = String(locale, length);
+	}
 #else // DETECTLANG
 	_syslang = "C";
 #endif // DETECTLANG


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list