当前位置: 首页>>代码示例>>PHP>>正文


PHP LanguageConverter::translate方法代码示例

本文整理汇总了PHP中LanguageConverter::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP LanguageConverter::translate方法的具体用法?PHP LanguageConverter::translate怎么用?PHP LanguageConverter::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LanguageConverter的用法示例。


在下文中一共展示了LanguageConverter::translate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:LanguageUz.php

示例2: 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;
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:21,代码来源:LanguageKk.php

示例3: 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);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:42,代码来源:LanguageKu.php

示例4: 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;
 }
开发者ID:lourinaldi,项目名称:mediawiki,代码行数:39,代码来源:LanguageKk.php


注:本文中的LanguageConverter::translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。