]> git.joonet.de Git - adminer.git/commitdiff
Compress each translation separately
authorJakub Vrana <jakub@vrana.cz>
Mon, 3 Sep 2012 22:59:05 +0000 (15:59 -0700)
committerJakub Vrana <jakub@vrana.cz>
Fri, 7 Sep 2012 15:31:25 +0000 (08:31 -0700)
adminer/include/lang.inc.php
compile.php

index 760c3639d09a98434e6365addc5e14256b19bbd0..edd1efbd5861f0d9052b17cfa5a00cd8cbc16ccd 100644 (file)
@@ -47,7 +47,7 @@ function get_lang() {
 */
 function lang($idf, $number = null) {
        global $LANG, $translations;
-       $translation = (isset($translations[$idf]) ? $translations[$idf] : $idf);
+       $translation = ($translations[$idf] ? $translations[$idf] : $idf);
        if (is_array($translation)) {
                $pos = ($number == 1 ? 0
                        : ($LANG == 'cs' || $LANG == 'sk' ? ($number && $number < 5 ? 1 : 2) // different forms for 1, 2-4, other
@@ -78,6 +78,7 @@ function switch_lang() {
        echo "</div>\n</form>\n";
 }
 
+// used in compiled version
 function lzw_decompress($binary) {
        // convert binary string to codes
        $dictionary_count = 256;
index 4652ac93ec51b25d77411cc2170ae84c89089372..e25620410f0606fd5e6f2337257335e6c5fb7e08 100755 (executable)
@@ -103,27 +103,30 @@ function put_file_lang($match) {
        if ($_SESSION["lang"]) {
                return "";
        }
-       $all_translations = array();
+       $return = "";
        foreach ($langs as $lang => $val) {
                include dirname(__FILE__) . "/adminer/lang/$lang.inc.php"; // assign $translations
                $translation_ids = array_flip($lang_ids); // default translation
                foreach ($translations as $key => $val) {
                        if ($val !== null) {
-                               $translation_ids[$lang_ids[$key]] = $val;
+                               $translation_ids[$lang_ids[$key]] = implode("\t", (array) $val);
                        }
                }
-               $all_translations[$lang] = $translation_ids;
+               $return .= "\n\t\tcase \"$lang\": \$compressed = '" . add_apo_slashes(lzw_compress(implode("\n", $translation_ids))) . "'; break;";
        }
-       $all_translations = serialize($all_translations);
-       $translations_version = crc32($all_translations);
+       $translations_version = crc32($return);
        return '$translations = &$_SESSION["translations"];
 if ($_SESSION["translations_version"] != ' . $translations_version . ') {
        $translations = array();
        $_SESSION["translations_version"] = ' . $translations_version . ';
 }
 if ($_GET["lang"] || !$translations) {
-       $all_translations = unserialize(lzw_decompress(\'' . add_apo_slashes(lzw_compress($all_translations)) . '\'));
-       $translations = $all_translations[$LANG];
+       switch ($LANG) {' . $return . '
+       }
+       $translations = array();
+       foreach (explode("\n", lzw_decompress($compressed)) as $val) {
+               $translations[] = (strpos($val, "\t") ? explode("\t", $val) : $val);
+       }
 }
 ';
 }