Compress each translation separately
This commit is contained in:
parent
ccd1246666
commit
0317638e80
|
@ -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;
|
||||
|
|
17
compile.php
17
compile.php
|
@ -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);
|
||||
}
|
||||
}
|
||||
';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue