translit
result_type CUtil::translit( string str, string lang, array params () );
The method transliterates a text string. Static method.
Parameters
Parameter | Description |
---|---|
str | Text string to be transliterated |
lang | Source language to be transliterated |
params | Array of parameters:
|
You can access and configure the dictionary with transliterations for each language available in the system inside the file /main/lang/
TRANS_FROM - list of characters subject to transliteration.
List of characters must be listed in the alphabetic order in both upper and lower cases (first lower and then upper case), separated by commas and without space bars.
TRANS_TO - list of characters used for replacement.
Example for German language:
- $MESS["TRANS_FROM"] = "ä,ö,ß,ü,Ä,Ö,ß,Ü";
- $MESS["TRANS_TO"] = "ae,oe,ss,ue,AE,OE,SS,UE";
Example for Polish language:
- $MESS["TRANS_FROM"] = "ą,ć,ę,ł,ń,ó,ś,ź,ż,Ą,Ć,Ę,Ł,Ń,Ó,Ś,Ź,Ż";
- $MESS["TRANS_TO"] = "a,c,e,l,n,o,s,z,z,A,C,E,L,N,O,S,Z,Z";
In case such match is not set, unique language characters are replaced with the symbol "-" in the generated URL.
Example
<? $name = "Text*89"; $arParams = array("replace_space"=>"-","replace_other"=>"-"); $trans = Cutil::translit($name,"en",$arParams); echo '<pre>'; var_dump($trans); echo '</pre>'; ?>
© «Bitrix24», 2001-2024