sensitivesouris/simpletransliteration

A simple library that transliterate text to selected language.

dev-master 2019-08-14 19:17 UTC

This package is auto-updated.

Last update: 2024-09-15 06:45:55 UTC


README

SimpleTransliteration it's a library that helps with transliteration from one language to another.

Requirements

PHP >= 7.1

Installtaion

Composer: composer require sensitivesouris/simpletransliteration

You can use this library without composer, but then you need to register an autoloader function.

Basic usage

$st = new IvanMuir\SimpleTransliteration\SimpleTransliteration();

$transliterized = $st->transliterate("ru", "en", "Съешь еще этих мягких французских булок, да выпей чаю.");

echo $transliterized; //Sesh eshche etih myagkih francuzskih bulok, da vypey chau.

Custom dictionaries

By default, there is only one dictionary that contains Cyrillic chars with their aliases in English. To add custom folder with more dictionaries use:

$st = new IvanMuir\SimpleTransliteration\SimpleTransliteration();

$st->setDictionariesLocation("path/to/dictionaries");

All dictionaries must me in json format, have name that contains SourceLang_OutputLang, ex. ru_en.json and this structure:

{  
  "А": "A",  
  "Б": "B",  
  "В": "V",
...
}

where first chat - input char and second char - output char.