Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Format numbers in translations

  • Loading branch information...
commit 7f1fcc228657aa1a5ea547948975f937764d0067 1 parent a2378af
@vrana authored
Showing with 10 additions and 3 deletions.
  1. +6 −2 adminer/include/lang.inc.php
  2. +1 −0  changes.txt
  3. +3 −1 compile.php
View
8 adminer/include/lang.inc.php
@@ -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() {
View
1  changes.txt
@@ -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
View
4 compile.php
@@ -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 {

0 comments on commit 7f1fcc2

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