Translates a string into the current language.

@param   string   $string  The format string.
@param   integer  $n       The number of items
@return  string   The translated string or the key is $script is true
968530
public function txts($string, $n)
	{
		$args  = func_get_args();
		$count = count($args);

		if ($count > 1)
		{
			// Try the key from the language plural potential suffixes
			$found = false;
			$suffixes = $this->getPluralSuffixes((int) $n);
			array_unshift($suffixes, (int) $n);
			foreach ($suffixes as $suffix)
			{
				$key = $string . '_' . $suffix;
				if ($this->hasKey($key))
				{
					$found = true;
					break;
				}
			}
			if (!$found)
			{
				// Not found so revert to the original.
				$key = $string;
			}
			if (is_array($args[$count - 1]))
			{
				$args[0] = $this->translate(
					$key, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
					array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
				);
			}
			else
			{
				$args[0] = $this->translate($key);
			}
			return call_user_func_array('sprintf', $args);
		}
		elseif ($count > 0)
		{

			// Default to the normal sprintf handling.
			$args[0] = $this->translate($string);
			return call_user_func_array('sprintf', $args);
		}

		return '';
	}
1134511
public function read($n)
    {
        if ($n <= 0) {
            return '';
        }
        if (!isset($this->bev)) {
            return false;
        }
        $read = $this->bev->read($n);
        if ($read === null) {
            return false;
        }
        return $read;
    }
1035634
public static function convertEncoding($string)
    {
        $to     = 'UTF-8';
        $from   = self::WEB_SERVICE_CHARSET;
        $str = false;
        
        if (function_exists('iconv')) {
            $str = iconv($from, $to . '//TRANSLIT', $string);
        } elseif (function_exists('mb_convert_encoding')) {
            $str = mb_convert_encoding($string, $to, $from);
        }

        if ($str === false) {
            $str = $string;
        }

        return $str;
    }
1346728
public static function cliMessage($string)
    {
        $preString = '  | ';
        if (is_array($string)) {
            echo $preString.implode("\n==> ", $string)."\n";
        } else {
            echo $preString.$string."\n";
        }
    }
211052
public static function translit($string){
		//if(function_exists('mb_strtr')){
		//	return mb_strtr($string,self::$translitconverter);
		//	}
		if(function_exists('mb_str_split')){
			return str_replace(
				mb_str_split(array_keys(self::$translitconverter)),
				mb_str_split(array_values(self::$translitconverter)),
				$string);
			}else{
			return str_replace(
				array_keys(self::$translitconverter),
				array_values(self::$translitconverter),
				$string);
			}
		}
276557
public static function translate($string, Translation $translation = null) {
		if ($translation !== null) {
			$translation = self::get($translation->language, $translation->application_name);
		} else {
			$translation = self::get(\Application::get()->language, \Application::get()->name);
		}

		return $translation->translate_string($string);
	}
265853
public function translate($string, $namespace, $arguments = array())
    {
        // Load the language file for the given namespace if the language file isn't loaded
        if (!isset($this->translatedStrings[$namespace]) || !is_array($this->translatedStrings[$namespace])) {
            $this->loadLanguageFileForNamespace($namespace);
        }
        
        // If no translation for the original string is available or the string is not translated 
        // return the original string to the caller.
        if (!isset($this->translatedStrings[$namespace][$string]) || $this->translatedStrings[$namespace][$string] == '') {
            return $this->replacePlaceholders($string, $arguments);
        }
        
        return $this->replacePlaceholders($this->translatedStrings[$namespace][$string], $arguments);
    }
612150
public function transform($string)
    {
        $string = $this->transliterator->transliterate($string);
        if ($string === false) {
            throw new UnexpectedValueException($this->transliterator->getErrorMessage(), $this->transliterator->getErrorCode());
        }
        return $string;
    }
252068
public static function translateByArray($string)
    {
        return preg_replace(array_keys(self::$ascii), array_values(self::$ascii), $string);
    }
1373939
private function select_string($n) {
        $string = $this->get_plural_forms();
        $string = str_replace('nplurals', "\$total", $string);
        $string = str_replace("n", $n, $string);
        $string = str_replace('plural', "\$plural", $string);

        $total = 0;
        $plural = 0;

        eval("$string");
        if ($plural >= $total) $plural = $total - 1;
        return $plural;
    }
679380
public function startsWith($string)
	{
		$string = static::_convertString($string, $this->encoding);
		return $string === $this->substring(0, mb_strlen($string, $this->encoding)-1)->__toString();
	}
318657
static function toNFD( $string ) {
		if ( NORMALIZE_INTL ) {
			return normalizer_normalize( $string, Normalizer::FORM_D );
		} elseif ( preg_match( '/[\x80-\xff]/', $string ) ) {
			return self::NFD( $string );
		} else {
			return $string;
		}
	}
498083
static function repeat($str, $n) {
        $nstr = '';

        for ($i = 0; $i < $n; $i++) {
            $nstr .= $str;
        }

        return $nstr;
    }
455076
public function isKanji(string $string):bool{
		$i   = 0;
		$len = \strlen($string);

		while($i + 1 < $len){
			$c = ((0xff&\ord($string[$i])) << 8)|(0xff&\ord($string[$i + 1]));

			if(!($c >= 0x8140 && $c <= 0x9FFC) && !($c >= 0xE040 && $c <= 0xEBBF)){
				return false;
			}

			$i += 2;
		}

		return $i >= $len;
	}
21362
public static function toUtf8($string)
    {
        $string = explode('@', $string);

        // Not addressing UTF-8 user names
        $new = $string[0];

        if (!empty($string[1])) {
            $domainExploded = explode('.', $string[1]);
            $newdomain      = '';

            foreach ($domainExploded as $domainex) {
                $domainex  = static::decode($domainex);
                $newdomain .= $domainex . '.';
            }

            $newdomain = substr($newdomain, 0, -1);
            $new       = $new . '@' . $newdomain;
        }

        return $new;
    }
722289
private static function replaceForNativeNormalize( $string ) {
		$string = preg_replace(
			'/[\x00-\x08\x0b\x0c\x0e-\x1f]/',
			Constants::UTF8_REPLACEMENT,
			$string );
		$string = str_replace( Constants::UTF8_FFFE, Constants::UTF8_REPLACEMENT, $string );
		$string = str_replace( Constants::UTF8_FFFF, Constants::UTF8_REPLACEMENT, $string );

		return $string;
	}
273363
public static function fromString($string, Translations $translations, array $options = [])
    {
        $options += static::$options;

        $functions = new JsFunctionsScanner($string);
        $functions->saveGettextFunctions($translations, $options);
    }