incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1385144 - /incubator/ooo/ooo-site/trunk/content/download/test/new/download.js
Date Sat, 15 Sep 2012 17:55:51 GMT
Author: marcus
Date: Sat Sep 15 17:55:50 2012
New Revision: 1385144

URL: http://svn.apache.org/viewvc?rev=1385144&view=rev
Log:
Combined the 2 language functions into a single function

Modified:
    incubator/ooo/ooo-site/trunk/content/download/test/new/download.js

Modified: incubator/ooo/ooo-site/trunk/content/download/test/new/download.js
URL: http://svn.apache.org/viewvc/incubator/ooo/ooo-site/trunk/content/download/test/new/download.js?rev=1385144&r1=1385143&r2=1385144&view=diff
==============================================================================
--- incubator/ooo/ooo-site/trunk/content/download/test/new/download.js (original)
+++ incubator/ooo/ooo-site/trunk/content/download/test/new/download.js Sat Sep 15 17:55:50
2012
@@ -1,17 +1,18 @@
 /*
  * Overview of all functions defined below
- * function getArray       ()
- * function getLanguageISO ()
- * function hasMirrorLink  ()
- * function getLink        ()
- * function getPlatform    ()
- * function openItem       ( itemid, uri )
+ * function getLanguage   ()
+ * function hasMirrorLink ()
+ * function getLink       ()
+ * function getPlatform   ()
+ * function openItem      ( itemid, uri )
  */
 
 /*
  * define global variables
  */
 
+var LANG_ISO		= "";
+var LANG_ARRAY		= "";
 var PLATFORM		= "";
 var UI_PLATFORM		= "";
 var EXTENSION		= "";
@@ -20,10 +21,10 @@ var CHECKSUM_MD5	= "";
 var CHECKSUM_SHA256	= "";
 
 /*
- * get array for language
+ * get array and ISO code for language
  * depends on nl_language
  */
-function getArray() {
+function getLanguage() {
 	var language = "";
 
 	if ( NL_LANGUAGE != "" )
@@ -53,88 +54,44 @@ function getArray() {
 	var thisLanguageSet  = languages[ languageCode ];
 	if ( thisLanguageSet == null ) {
 		// language code not found inside array
-		languageCode     = "en";
-		regionCode       = "us";
-		thisLanguageSet  = languages[ languageCode ];
+		language	= "en-US";
+		languageCode	= "en";
+		regionCode	= "us";
+		thisLanguageSet	= languages[ languageCode ];
 	}
 
-	if ( regionCode != null )
+	if ( regionCode != null ) {
+		// fix for Port. pt-PT downloads named only pt without region code!
+		if ( regionCode == "pt" && languageCode == "pt" )
+			language = languageCode;
+
 		// found additional region code
-		if ( thisLanguageSet[ regionCode ] != null )
+		if ( thisLanguageSet[ regionCode ] != null ) {
 			// choose langCode-regionCode
+			language     = languageCode + "-" + regionCode.toUpperCase();
 			thisLanguage = thisLanguageSet[ regionCode ];
-		else
+		} else {
 			// choose default
 			thisLanguage = thisLanguageSet[ "-" ];
 			if ( languageCode == "en" ) {
 				// special case, default is en-US for en-XX
-				regionCode       = "us";
-				thisLanguageSet  = languages[ languageCode ];
-				thisLanguage     = thisLanguageSet[ regionCode ];
+				language	= "en-US";
+				regionCode	= "us";
+				thisLanguageSet	= languages[ languageCode ];
+				thisLanguage	= thisLanguageSet[ regionCode ];
+			} else {
+				language	= languageCode;
 			}
-	else
+		}
+	} else {
 		// choose default for none given region code
 		thisLanguage = thisLanguageSet[ "-" ];
+	}
 
-	LANG_ARRAY  = thisLanguage;
-	NATIVE_LANG = thisLanguage[ 2 ];
-	return thisLanguage;
-}
-
-/*
- * get language for user-language in ISO format
- * depends on nl_language
- */
-function getLanguageISO() {
-	var language = "";
-
-	if ( NL_LANGUAGE != "" )
-		language = NL_LANGUAGE;
-	else if ( navigator.language )
-		language = navigator.language;
-	else if ( navigator.userLanguage )
-		language = navigator.userLanguage;
-	else if ( navigator.systemLanguage )
-		language = navigator.systemLanguage;
-
-	// Convert "en" to "en-US" as well since en-US build is the canonical
-	// translation, and thus better tested.
-	if ( !language || language == "" || language == "null" || language == "en" )
-		language = "en-US";
-	if ( language == "pt" )
-		language = "pt-PT";
-
-	// Konqueror uses '_' where other browsers use '-'.
-	if ( language.indexOf( "_" ) != -1 )
-		language = language.split( "_" ).join( "-" );
-
-	language         = language.toLowerCase();
-	var languageCode = language.split( "-" )[ 0 ];
-	var regionCode   = language.split( "-" )[ 1 ];
-
-	var thisLanguageSet  = languages[ languageCode ];
-	if ( thisLanguageSet == null )
-		language = "en-US";
-	else if ( regionCode  != null ) {
-		if ( regionCode == "pt" && languageCode == "pt" )
-			// fix for Port. pt-PT downloads named only pt without region code!
-			language = languageCode;
-		if ( thisLanguageSet[ regionCode ] != null )
-			// choose langCode-regionCode
-			language = languageCode + "-" + regionCode.toUpperCase();
-		else
-			// choose default
-			if ( languageCode == "en" )
-				// special case, default is en-US for en-XX
-				language = "en-US";
-			else
-				language = languageCode;
-	} else
-		// choose default
-		language = languageCode;
-
-	LANG_ISO = language;
-	return language;
+	LANG_ISO	= language;
+	LANG_ARRAY	= thisLanguage;
+	NATIVE_LANG	= thisLanguage[ 2 ];
+	// return thisLanguage;
 }
 
 /*
@@ -157,15 +114,12 @@ function hasMirrorLink() {
  * depends on array-list
  */
 function getLink() {
-	var file_link	= "";
-	var chk_link	= "";
-	LANG_ARRAY	= getArray();
-	LANG_ISO	= getLanguageISO();
+	var file_link = "";
+	var chk_link  = "";
 
+	getLanguage();
         getPlatform();
 
-	// alert( PLATFORM + "<br />" + UI_PLATFORM + "<br />" + EXTENSION );
-
 	if ( NL_LANGUAGE == "" )
 		NL_LANGUAGE = LANG_ISO;
 



Mime
View raw message