本文整理汇总了PHP中LanguageConverter类的典型用法代码示例。如果您正苦于以下问题:PHP LanguageConverter类的具体用法?PHP LanguageConverter怎么用?PHP LanguageConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LanguageConverter类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LanguageConverter
<?php
require_once 'classes/LanguageConverter.php';
$languageConverter = new LanguageConverter();
$str = "Gamarjoba samyaro!";
echo $languageConverter->convertString($str, 'geolat2utf8') . "\n";
$languageConverter->addCharMap('geolat2utf8MixTest', array('a' => 'A', 'b' => 'B', 'g' => 'G', 'd' => 'დ', 'e' => 'ე', 'v' => 'ვ', 'z' => 'ზ', 'T' => 'თ', 'i' => 'ი', 'k' => 'კ', 'l' => 'ლ', 'm' => 'მ', 'n' => 'ნ', 'o' => 'ო', 'p' => 'პ', 'J' => 'ჟ', 'r' => 'რ', 's' => 'ს', 't' => 'ტ', 'u' => 'უ', 'f' => 'ფ', 'q' => 'ქ', 'R' => 'ღ', 'y' => 'ყ', 'S' => 'შ', 'C' => 'ჩ', 'c' => 'ც', 'Z' => 'ძ', 'w' => 'წ', 'W' => 'ჭ', 'x' => 'ხ', 'j' => 'ჯ', 'h' => 'ჰ'));
echo $languageConverter->convertString($str, 'geolat2utf8MixTest', 'utf-8') . "\n";
echo "\n";
echo $languageConverter->convertStringByIndex($str, 'georgia', 'ascii', 'utf8') . "\n";
$languageConverter->addCharMapByIndex('georgia', 'ascii_1', array('A', 'B', 'G', 'D', 'E', 'V', 'Z', 'T', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'J', 'R', 'S', 'T', 'U', 'F', 'Q', 'R', 'Y', 'S', 'C', 'C', 'Z', 'W', 'W', 'X', 'J', 'H'));
echo "\n";
echo $languageConverter->convertStringByIndex('ÂÀÌÀÒãÏÁÀ ÓÀÌÚÀÒÏ', 'georgia', 'ascii_1', 'stlat') . "\n";
示例2: array
/**
* @param Language $langobj
* @param string $maincode
* @param array $variants
* @param array $variantfallbacks
* @param array $flags
* @param array $manualLevel
*/
function __construct($langobj, $maincode, $variants = array(), $variantfallbacks = array(), $flags = array(), $manualLevel = array())
{
$this->mDescCodeSep = ':';
$this->mDescVarSep = ';';
parent::__construct($langobj, $maincode, $variants, $variantfallbacks, $flags, $manualLevel);
$names = array('gan' => '原文', 'gan-hans' => '简体', 'gan-hant' => '繁體');
$this->mVariantNames = array_merge($this->mVariantNames, $names);
}
示例3: array
function __construct($langobj, $maincode, $variants = array(), $variantfallbacks = array(), $flags = array(), $manualLevel = array())
{
$this->mDescCodeSep = ':';
$this->mDescVarSep = ';';
parent::__construct($langobj, $maincode, $variants, $variantfallbacks, $flags, $manualLevel);
$names = array('zh' => '原文', 'zh-hans' => '简体', 'zh-hant' => '繁體', 'zh-cn' => '大陆', 'zh-tw' => '台灣', 'zh-hk' => '香港', 'zh-mo' => '澳門', 'zh-sg' => '新加坡', 'zh-my' => '大马');
$this->mVariantNames = array_merge($this->mVariantNames, $names);
}
示例4: translate
function translate($text, $toVariant)
{
if ($toVariant == 'uz-cyrl') {
$text = str_replace('ye', 'е', $text);
$text = str_replace('Ye', 'Е', $text);
$text = str_replace('YE', 'Е', $text);
// "е" after consonants, otherwise "э" (see above)
$text = preg_replace('/([BVGDJZYKLMNPRSTFXCWQʻ‘H])E/u', '$1Е', $text);
$text = preg_replace('/([bvgdjzyklmnprstfxcwqʻ‘h])e/ui', '$1е', $text);
}
return parent::translate($text, $toVariant);
}
示例5: translate
/**
* It translates text into variant, specials:
* - ommiting roman numbers
*/
function translate($text, $toVariant)
{
$breaks = '[^\\w\\x80-\\xff]';
// regexp for roman numbers
$roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
$reg = '/^' . $roman . '$|^' . $roman . $breaks . '|' . $breaks . $roman . '$|' . $breaks . $roman . $breaks . '/';
$matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
$m = array_shift($matches);
$ret = $this->mTables[$toVariant]->replace($m[0]);
$mstart = $m[1] + strlen($m[0]);
foreach ($matches as $m) {
$ret .= substr($text, $mstart, $m[1] - $mstart);
$ret .= parent::translate($m[0], $toVariant);
$mstart = $m[1] + strlen($m[0]);
}
return $ret;
}
示例6: autoConvert
/**
* An ugly function wrapper for parsing Image titles
* (to prevent image name conversion)
*
* @param $text string
* @param $toVariant bool
*
* @return string
*/
function autoConvert($text, $toVariant = false)
{
global $wgTitle;
if (is_object($wgTitle) && $wgTitle->getNameSpace() == NS_FILE) {
$imagename = $wgTitle->getNsText();
if (preg_match("/^{$imagename}:/", $text)) {
return $text;
}
}
return parent::autoConvert($text, $toVariant);
}
示例7: findVariantLink
/**
* A function wrapper:
* - if there is no selected variant, leave the link
* names as they were
* - do not try to find variants for usernames
*
* @param string &$link
* @param Title &$nt
* @param bool $ignoreOtherCond
*/
function findVariantLink(&$link, &$nt, $ignoreOtherCond = false)
{
// check for user namespace
if (is_object($nt)) {
$ns = $nt->getNamespace();
if ($ns == NS_USER || $ns == NS_USER_TALK) {
return;
}
}
$oldlink = $link;
parent::findVariantLink($link, $nt, $ignoreOtherCond);
if ($this->getPreferredVariant() == $this->mMainLanguageCode) {
$link = $oldlink;
}
}
示例8: getConvRuleTitle
/**
* Get the conversion rule title, if any.
*
* @return string
*/
public function getConvRuleTitle()
{
return $this->mConverter->getConvRuleTitle();
}
示例9: translate
/**
* It translates text into variant, specials:
* - ommiting roman numbers
*
* @param string $text
* @param bool $toVariant
*
* @throws MWException
* @return string
*/
function translate($text, $toVariant)
{
$this->loadTables();
/* From Kazakh interface, maybe we need it later
$breaks = '[^\w\x80-\xff]';
// regexp for roman numbers
$roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
$roman = '';
$reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
$matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
$m = array_shift($matches);
if( !isset( $this->mTables[$toVariant] ) ) {
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
}
$ret = $this->mTables[$toVariant]->replace( $m[0] );
$mstart = $m[1]+strlen($m[0]);
foreach($matches as $m) {
$ret .= substr($text, $mstart, $m[1]-$mstart);
$ret .= parent::translate($m[0], $toVariant);
$mstart = $m[1] + strlen($m[0]);
}
return $ret;
*/
if (!isset($this->mTables[$toVariant])) {
throw new MWException("Broken variant table: " . implode(',', array_keys($this->mTables)));
}
return parent::translate($text, $toVariant);
}
示例10: translate
/**
* It translates text into variant
*
* @param string $text
* @param string $toVariant
*
* @return string
*/
function translate($text, $toVariant)
{
$text = parent::translate($text, $toVariant);
switch ($toVariant) {
case 'kk-cyrl':
case 'kk-kz':
$letters = KK_L_UC . KK_L_LC . 'ʺʹ#0123456789';
break;
case 'kk-latn':
case 'kk-tr':
$letters = KK_C_UC . KK_C_LC . '№0123456789';
break;
case 'kk-arab':
case 'kk-cn':
$letters = KK_C_UC . KK_C_LC . ',;\\?%\\*№0123456789';
break;
default:
return $text;
}
// disable conversion variables like $1, $2...
$varsfix = '\\$[0-9]';
$matches = preg_split('/' . $varsfix . '[^' . $letters . ']+/u', $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
$mstart = 0;
$ret = '';
foreach ($matches as $m) {
$ret .= substr($text, $mstart, $m[1] - $mstart);
$ret .= $this->regsConverter($m[0], $toVariant);
$mstart = $m[1] + strlen($m[0]);
}
return $ret;
}
示例11: markNoConversion
function markNoConversion($text, $noParse = false)
{
if ($noParse || preg_match("/^https?:\\/\\/|ftp:\\/\\/|irc:\\/\\//", $text)) {
return parent::markNoConversion($text);
}
return $text;
}