/** * format a given number of bytes in IEC 80000-13:2008 notation (localized) * * @access public * @static * @param int $size * @return string */ public static function size_humanreadable($size) { $iec = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'); $i = 0; while ($size / 1024 >= 1) { $size = $size / 1024; $i++; } return number_format($size, $i ? 2 : 0, '.', ' ') . ' ' . i18n::_($iec[$i]); }
/** * return JSON encoded message and exit * * @access private * @param bool $status * @param string $message * @param array $other * @return void */ private function _return_message($status, $message, $other = array()) { $result = array('status' => $status); if ($status) { $result['message'] = i18n::_($message); } else { $result['id'] = $message; } $result += $other; $this->_json = json_encode($result); }
/** * get a key from the configuration, typically the main section or all keys * * @param string $key if empty, return all configuration options * @param string $section defaults to main * @throws Exception * return mixed */ public function getSection($section) { if (!array_key_exists($section, $this->_configuration)) { throw new Exception(i18n::_('ZeroBin requires configuration section [%s] to be present in configuration file.', $section), 3); } return $this->_configuration[$section]; }
public function testVariableInjection() { $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'foobar'; i18n::loadTranslations(); $this->assertEquals('some string + 1', i18n::_('some %s + %d', 'string', 1), 'browser language en'); }