Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Compress each translation separately

  • Loading branch information...
commit 8b87541f71ac20b13be17b1a4bd89a4b800fcdd3 1 parent 19f955b
Jakub Vrána authored September 03, 2012
4  adminer/include/lang.inc.php
@@ -47,7 +47,7 @@ function get_lang() {
47 47
 */
48 48
 function lang($idf, $number = null) {
49 49
 	global $LANG, $translations;
50  
-	$translation = (isset($translations[$idf]) ? $translations[$idf] : $idf);
  50
+	$translation = ($translations[$idf] ? $translations[$idf] : $idf);
51 51
 	if (is_array($translation)) {
52 52
 		$pos = ($number == 1 ? 0
53 53
 			: ($LANG == 'cs' || $LANG == 'sk' ? ($number && $number < 5 ? 1 : 2) // different forms for 1, 2-4, other
@@ -78,7 +78,7 @@ function switch_lang() {
78 78
 	echo "</div>\n</form>\n";
79 79
 }
80 80
 
81  
-
  81
+// used in compiled version
82 82
 function lzw_decompress($binary) {
83 83
 	// convert binary string to codes
84 84
 	$dictionary_count = 256;
17  compile.php
@@ -103,27 +103,30 @@ function put_file_lang($match) {
103 103
 	if ($_SESSION["lang"]) {
104 104
 		return "";
105 105
 	}
106  
-	$all_translations = array();
  106
+	$return = "";
107 107
 	foreach ($langs as $lang => $val) {
108 108
 		include dirname(__FILE__) . "/adminer/lang/$lang.inc.php"; // assign $translations
109 109
 		$translation_ids = array_flip($lang_ids); // default translation
110 110
 		foreach ($translations as $key => $val) {
111 111
 			if ($val !== null) {
112  
-				$translation_ids[$lang_ids[$key]] = $val;
  112
+				$translation_ids[$lang_ids[$key]] = implode("\t", (array) $val);
113 113
 			}
114 114
 		}
115  
-		$all_translations[$lang] = $translation_ids;
  115
+		$return .= "\n\t\tcase \"$lang\": \$compressed = '" . add_apo_slashes(lzw_compress(implode("\n", $translation_ids))) . "'; break;";
116 116
 	}
117  
-	$all_translations = serialize($all_translations);
118  
-	$translations_version = crc32($all_translations);
  117
+	$translations_version = crc32($return);
119 118
 	return '$translations = &$_SESSION["translations"];
120 119
 if ($_SESSION["translations_version"] != ' . $translations_version . ') {
121 120
 	$translations = array();
122 121
 	$_SESSION["translations_version"] = ' . $translations_version . ';
123 122
 }
124 123
 if ($_GET["lang"] || !$translations) {
125  
-	$all_translations = unserialize(lzw_decompress(\'' . add_apo_slashes(lzw_compress($all_translations)) . '\'));
126  
-	$translations = $all_translations[$LANG];
  124
+	switch ($LANG) {' . $return . '
  125
+	}
  126
+	$translations = array();
  127
+	foreach (explode("\n", lzw_decompress($compressed)) as $val) {
  128
+		$translations[] = (strpos($val, "\t") ? explode("\t", $val) : $val);
  129
+	}
127 130
 }
128 131
 ';
129 132
 }

0 notes on commit 8b87541

Please sign in to comment.
Something went wrong with that request. Please try again.