PHP Classes

Cyrillic to Latin: Translite text between cyrillic and latin

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 55%Total: 1,990 All time: 1,977 This week: 673Up
Version License Categories
cyrlat 1.0FreewareLocalization, Text processing, Conver...
Description 

Author

This is a simple class can convert text between representations using cyrillic and latin character sets.

The class can convert text in both directions: cyrillic to latin and latin to cyrillic.

Picture of Yaroslav Shapoval
Name: Yaroslav Shapoval <contact>
Classes: 1 package by
Country: Belarus Belarus

 

Details

INTRO This class *Cyrillic to Latin (translit)* provides methods for converting (translitering) symbols. License: FREEWARE (please, leave my copyright!). What you need to work with this class: No additional extensions/pears/pecls needed. functions: string cyr2lat(input string) - cyrillic to latin convert string lat2cyr(input string) - latin to cyrillic convert variables: array $cyr - cyrillic symbols array $lat - latin replacement for cyrillic symbols array $lat_additional - additional latin symbols set (for non-usuall replacements) array $cyr_additional - additional cyrillic symbols (to replace non-usuall latin symbol replacements) BUGS Known bugs and _undocumented features_: + Work only with Windows-1251 codepage. If you want use it with koi8-r or other, use php-standard function convert_cyr_string(...) on your input, like <code> #... $input=convert_cyr_string($input, "k", "w"); //convert from KOI8-R to Windows-1251 #... </code> + Some symbolsets have wrong translitering (by their dual nature). For example: "Shoroh" is "Øîðîõ" and "Shvatka" is "Øâàòêà" (not "Ñõâàòêà"). Bugfix: manual editing of outputed string :) # Ñëèæêîì óæ îí âåëèê è ìîãó÷, ýòîò Ðóññêèé ÿçûê. Âñ¸ àëãîðèòìîì íå îïèøåøü. + Class represent my own vision of translit rules. If you want "Jopa" instead of "Zhopa" - edit $cyr and $lat (!notice) symbols order matters in arrays $cyr, $lat, $cyr_additional, $lat_additional! USAGE The usage is rather simple: <code> #------->8------test.php------------ <?php require_once("cyrlat.class.php");// include main class $text=new CyrLat; // initialize $text as $input="Ïðèâåò, Ìèð!"; echo $text->cyr2lat($input); echo "<hr>\n"; $input="Privet, Mir!"; echo $text->lat2cyr($input); ?> #-------8<--------------------------- </code> See /examples/ for more examples. You can simply integrate it to forums, forms, sms-senders etc. Da pribudet s vami Sila!

  Files folder image Files (12)  
File Role Description
Files folder imageexamples (3 files, 1 directory)
Plain text file cyrlat.class.php Class main class
Accessible without login Plain text file readme.txt Doc. English readme text
Accessible without login Plain text file test.php Example main classsymple example

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,990
This week:0
All time:1,977
This week:673Up
User Ratings User Comments (2)
 All time
Utility:62%StarStarStarStar
Consistency:62%StarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:55%StarStarStar
Rank:2002
 
Excellent
15 years ago (kishore kumar)
80%StarStarStarStarStar
Which character encoding is assumed? I am having trouble maki...
17 years ago (Judith Meyer)
55%StarStarStar