Commits

Anonymous committed 6a2d47f

Number helper uses lang files
Bytes use whole numbers (123.0 bytes is just silly)

  • Participants
  • Parent commits 9680822

Comments (0)

Files changed (2)

system/helpers/number_helper.php

 {
 	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;

system/language/english/number_lang.php

+<?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 */