]> git.joonet.de Git - adminer.git/commitdiff
Format numbers in translations
authorJakub Vrana <jakub@vrana.cz>
Tue, 5 Jun 2012 00:44:04 +0000 (17:44 -0700)
committerJakub Vrana <jakub@vrana.cz>
Tue, 5 Jun 2012 00:44:04 +0000 (17:44 -0700)
adminer/include/lang.inc.php
changes.txt
compile.php

index 8f047cd1a4a17a4f984bba414b9ea524141ae382..72a0c0f0815631f06a2aba6ffa55c94b18db00b6 100644 (file)
@@ -45,7 +45,7 @@ function get_lang() {
 */
 function lang($idf, $number = null) {
        global $LANG, $translations;
-       $translation = $translations[$idf];
+       $translation = (isset($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
@@ -60,7 +60,11 @@ function lang($idf, $number = null) {
        }
        $args = func_get_args();
        array_shift($args);
-       return vsprintf(($translation !== null ? $translation : $idf), $args);
+       $format = str_replace("%d", "%s", $translation);
+       if ($format != $translation) {
+               $args[0] = number_format($number, 0, ".", lang(','));
+       }
+       return vsprintf($format, $args);
 }
 
 function switch_lang() {
index 9dd4d3c8a2db4e34f60b430e64f419d142b761c9..90b21d716a46293bb6907f48d933818b5007fcc9 100644 (file)
@@ -5,6 +5,7 @@ Link to descending order
 Warn about selecting data without index
 Allow specifying database in login form
 Link to original table in EXPLAIN of SELECT * FROM table t
+Format numbers in translations
 MySQL: inform about disabled event_scheduler
 SQLite: support binary data
 PostgreSQL: approximate row count in table overview
index 8c7e36435aa9bcd3f4152c3443dcbfe0b5334244..3f736e0fb12a8aeb6cf05c02d65ea182078f59e2 100755 (executable)
@@ -51,7 +51,9 @@ function put_file($match) {
 function lang(\$translation, \$number) {
        \$pos = $match2[2]\t\t: " . (preg_match("~\\\$LANG == '$_SESSION[lang]'.* \\? (.+)\n~U", $match2[1], $match3) ? $match3[1] : "1") . '
        );
-       return sprintf($translation[$pos], $number);
+       $translation = str_replace("%d", "%s", $translation[$pos]);
+       $number = number_format($number, 0, ".", lang(\',\'));
+       return sprintf($translation, $number);
 }
 ';
        } else {