PHP Classes
elePHPant
Icontem

Cyrillic to Latin: Translite text between cyrillic and latin

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2005-10-26 (9 years ago) RSS 2.0 feedStarStarStar 59%Total: 1,943 All time: 1,910 This week: 1,199Up
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
Age: 31
All time rank: 14213 in Belarus Belarus
Week rank: 1465 Down4 in Belarus Belarus Down

Details provided by the author  
		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  
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

  Files folder image Files  /  examples  
File Role Description
Files folder imageAjaxTest (3 files, 1 directory)
  Accessible without login Plain text file cyr2lat_test.php Example cyrillic to latin symbols test
  Accessible without login Plain text file forms_test.php Example usage example with forms
  Accessible without login Plain text file lat2cyr_test.php Example latin to cyrillic symbols test

  Files folder image Files  /  examples  /  AjaxTest  
File Role Description
Files folder imagelib (3 files)
  Accessible without login Plain text file testAjax.php Example Ajax test script
  Accessible without login Plain text file lat2cyr.php Appl. loader
  Accessible without login Plain text file readme.txt Doc. Ajax test script

  Files folder image Files  /  examples  /  AjaxTest  /  lib  
File Role Description
  Accessible without login Plain text file config.php Conf. Ajax config file
  Accessible without login Plain text file Js.js Aux. Ajax JS file
  Accessible without login Plain text file php.php Aux. Ajax server

 Version Control Unique User Downloads Download Rankings  
 0%Total:1,943All time:1,910
 This week:0This week:1,199Up
User Ratings User Comments (2)  
 All time
Utility:66%StarStarStarStar
Consistency:66%StarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:946
 
Excellent
5 years ago (kishore kumar)
80%StarStarStarStarStar
Which character encoding is assumed? I am having trouble maki...
7 years ago (Judith Meyer)
55%StarStarStar