Format numbers in translations
This commit is contained in:
parent
a2378af008
commit
7f1fcc2286
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue