mggflow / transliterator
Tool for text transliteration by replacement relations.
v1.0.0
2022-07-13 01:20 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-11-13 06:09:49 UTC
README
About
This package can transliterate between languages using string replacements.
Available pairs:
- RU-EN
Usage
To install:
composer require mggflow/transliterator
Example:
// Create instanse of TransliteratorFabric.
$fabric = new TransliteratorFabric();
// Make Transliterator for EN-RU pair.
$enRu = $fabric->make("en", "ru");
if(is_null($enRu)){
throw new Exception("Language pair not found!");
}
$resultFromRuToEn = $enRu->reverse("Привет!");
// Result is "Privet!".
var_dump($resultFromRuToEn);
// Result is "Привет!".
$resultFromEnToRu = $enRu->direct($resultFromRuToEn);
var_dump($resultFromEnToRu);