diff options
author | Derek Allard <derek.allard@ellislab.com> | 2008-06-26 19:03:38 +0200 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2008-06-26 19:03:38 +0200 |
commit | 85f66ea6d2291c77a937305457592e24c85425ae (patch) | |
tree | b32a67e744308ef4032f957e37ef35dcd88689f4 | |
parent | 7f4d2f1f67bdab32137ecc2cc827158d7770980b (diff) |
Number helper uses lang files
Bytes use whole numbers (123.0 bytes is just silly)
-rw-r--r-- | system/helpers/number_helper.php | 13 | ||||
-rw-r--r-- | system/language/english/number_lang.php | 10 |
2 files changed, 18 insertions, 5 deletions
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index 23ba3a1bb..8c9e384eb 100644 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.php @@ -38,30 +38,33 @@ if ( ! function_exists('byte_format')) {
function byte_format($num)
{
+ $CI =& get_instance();
+ $CI->lang->load('number');
if ($num >= 1000000000000)
{
$num = round($num/1099511627776)/10;
- $unit = 'TB';
+ $unit = $CI->lang->line('terabyte_abbr');
}
elseif ($num >= 1000000000)
{
$num = round($num/107374182)/10;
- $unit = 'GB';
+ $unit = $CI->lang->line('gigabyte_abbr');
}
elseif ($num >= 1000000)
{
$num = round($num/104857)/10;
- $unit = 'MB';
+ $unit = $CI->lang->line('megabyte_abbr');
}
elseif ($num >= 1000)
{
$num = round($num/102)/10;
- $unit = 'KB';
+ $unit = $CI->lang->line('kilobyte_abbr');
}
else
{
- $unit = 'Bytes';
+ $unit = $CI->lang->line('bytes');
+ return number_format($num).' '.$unit;
}
return number_format($num, 1).' '.$unit;
diff --git a/system/language/english/number_lang.php b/system/language/english/number_lang.php new file mode 100644 index 000000000..f9b91661d --- /dev/null +++ b/system/language/english/number_lang.php @@ -0,0 +1,10 @@ +<?php
+
+$lang['terabyte_abbr'] = "TB";
+$lang['gigabyte_abbr'] = "GB";
+$lang['megabyte_abbr'] = "MB";
+$lang['kilobyte_abbr'] = "KB";
+$lang['bytes'] = "Bytes";
+
+/* End of file number_lang.php */
+/* Location: ./system/language/english/number_lang.php */
\ No newline at end of file |