當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。