pocketmine\lang\BaseLang::parseTranslation PHP Method

parseTranslation() protected method

protected parseTranslation ( $text, $onlyPrefix = null )
    protected function parseTranslation($text, $onlyPrefix = null)
    {
        $newString = "";
        $replaceString = null;
        $len = strlen($text);
        for ($i = 0; $i < $len; ++$i) {
            $c = $text[$i];
            if ($replaceString !== null) {
                if (ord($c) >= 0x30 and ord($c) <= 0x39 or ord($c) >= 0x41 and ord($c) <= 0x5a or ord($c) >= 0x61 and ord($c) <= 0x7a or $c === ".") {
                    $replaceString .= $c;
                } else {
                    if (($t = $this->internalGet(substr($replaceString, 1))) !== null and ($onlyPrefix === null or strpos($replaceString, $onlyPrefix) === 1)) {
                        $newString .= $t;
                    } else {
                        $newString .= $replaceString;
                    }
                    $replaceString = null;
                    if ($c === "%") {
                        $replaceString = $c;
                    } else {
                        $newString .= $c;
                    }
                }
            } elseif ($c === "%") {
                $replaceString = $c;
            } else {
                $newString .= $c;
            }
        }
        if ($replaceString !== null) {
            if (($t = $this->internalGet(substr($replaceString, 1))) !== null and ($onlyPrefix === null or strpos($replaceString, $onlyPrefix) === 1)) {
                $newString .= $t;
            } else {
                $newString .= $replaceString;
            }
        }
        return $newString;
    }