Translate original string

@param $string
@throws Exception
@return string
964225
public function translate($string) {

        // get selected signature

        if(empty($this->signature) === false) {
            if (array_key_exists($string, $this->signature) === false) {
                return $string;
            }
            return $this->signature[$string];
        }
        else {
            throw new Exception('Could not find translate signature');
        }
    }
735754
function _convertString($string)
    {
        // chop away beggining and ending quotes
        $string = substr($string, 1, strlen($string) - 2);
        if (strlen($string) > 255) {
            return $this->raiseError("String is too long");
        }

        if ($this->_BIFF_version == 0x0500) {
            return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string;
        } elseif ($this->_BIFF_version == 0x0600) {
            $encoding = 0;   // TODO: Unicode support
            return pack("CCC", $this->ptg['ptgStr'], strlen($string), $encoding).$string;
        }
    }
334968
public function translate($string)
    {
        $args = func_get_args();
        $translated = array_shift($args);
        $extraParams = $args;
        if (count($extraParams)>0)
        {
            $translated = vsprintf($translated, $extraParams);
        }

        return $translated;
    }
1233103
public static function createFromString($string)
    {
        $file = new SplTempFileObject(-1);

        if (null === $file->fwrite($string)) {
            throw new Exception("Cannot create file");
        }

        return new static($file);
    }
1166304
public static function extract($string) {
    if (mb_strlen($string) == 0) {
      throw new Exception('String ist leer, kann kein Verzeichnis extrahieren');
    }
    
    $path = dirname($string).DIRECTORY_SEPARATOR;
    try {
      $dir = new Dir($path);
    } catch (Exception $e) {
      throw new Exception('kann kein Verzeichnis aus dem extrahierten Verzeichnis "'.$path.'" erstellen: '.$e->getMessage());
    }
    
    return $dir;
  }
1274408
private function getEncoding(string &$string): string
    {
        # Check for the UTF-8 byte order mark
        if (substr($string, 0, 3) === self::UTF8) {
            $string = substr($string, 3);
            return self::UTF8;
        }

        # Check for the UTF-16 big endian byte order mark
        if (substr($string, 0, 2) === self::UTF16BE) {
            $string = substr($string, 2);
            return self::UTF16BE;
        }

        # Check for the UTF-16 little endian byte order mark
        if (substr($string, 0, 2) === self::UTF16LE) {
            $string = substr($string, 2);
            return self::UTF16LE;
        }

        return self::UNKNOWN;
    }
759959
public function transliterate($string)
	{
		if ($this->transliterator !== null)
		{
			return call_user_func($this->transliterator, $string);
		}

		$string = Latin::toAscii($string);
		$string = strtolower($string);

		return $string;
	}
1355771
private static function parseline($string){
        $string = str_replace(chr(10), "\\n", $string);
        $string = str_replace(chr(13), "\\n", $string);
        $string = str_replace("\f", "\\f", $string);
        return $string;
    }
151788
public function escape_string($string)
    {
        if (!$this->connection) {
            return $string;
        }

        if ($string === null) {
            return $string;
        }
        return $this->connection->escape_string($string);
    }
935605
public function setString($string)
	{
		if (null === $string)
		{
			throw new Exception('The string cannot be null.');
		}

		$this->string = $string;
		$this->hash   = md5($string);

		$this->convertHash();

		return $this;
	}
626990
public function translate($string,$source=false)
    {
        $this->source=$source;
        try {
            return $this->sendTranslate($string, $this->driver);
        } catch (\Exception $e) {
            //自动切换为备用渠道
            return $this->sendTranslate($string, $this->spare_driver);
        }
    }
1373331
protected function translit($string)
    {
        $stringOutput = (@iconv('UTF-8', 'ASCII//TRANSLIT', $string));
        if ($stringOutput === false) {
            $string = preg_replace('!([^0-9a-zA-Z\.,:;()/-_\s])!', '', $string); // use more explicit statement, alphanum dont do the job
            $stringOutput = (@iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $string));
            if ($stringOutput === false) {
                throw new \Exception('Cant convert '.$string);
            }
        }

        return $stringOutput;
    }
670090
public function replace($string)
    {
        foreach ($this->bag as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
849
private function applyTransformers(string $string): string
    {
        foreach (Transformer::getAll() as $transformer) {
            $string = $transformer($string);
        }

        return $string;
    }
959065
protected function replace($string)
    {
        foreach ($this->patterns as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
1075240
public function apply(string $string) : string
    {
        return str_replace($this->search, $this->replace, $string);
    }
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;
    }