Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Compress each translation separately

  • Loading branch information...
commit 0317638e807043e07741c8d26b58c32046b1189d 1 parent ccd1246
@vrana authored
Showing with 12 additions and 8 deletions.
  1. +2 −1  adminer/include/lang.inc.php
  2. +10 −7 compile.php
View
3  adminer/include/lang.inc.php
@@ -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;
View
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);
+ }
}
';
}
Please sign in to comment.
Something went wrong with that request. Please try again.