summaryrefslogtreecommitdiffstats
path: root/inc/dictionary.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/dictionary.inc.php')
-rw-r--r--inc/dictionary.inc.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php
index e366207f..4c98c63b 100644
--- a/inc/dictionary.inc.php
+++ b/inc/dictionary.inc.php
@@ -64,6 +64,31 @@ class Dictionary
}
/**
+ * Format given number using country-specific decimal point and thousands
+ * separator.
+ * @param float $num Number to format
+ * @param int $decimals How many decimals to display
+ */
+ public static function number(float $num, int $decimals = 0): string
+ {
+ static $dec = null, $tho = null;
+ if ($dec === null) {
+ if (LANG === 'de') {
+ $dec = ',';
+ $tho = '.';
+ } elseif (LANG !== 'en' && file_exists("lang/" . LANG . "/format.txt")) {
+ $tmp = file_get_contents("lang/" . LANG . "/format.txt");
+ $dec = $tmp[0];
+ $tho = $tmp[1];
+ } else {
+ $dec = '.';
+ $tho = ',';
+ }
+ }
+ return number_format($num, $decimals, $dec, $tho);
+ }
+
+ /**
* Get complete key=>value list for given module, file, language
*
* @param string $module Module name