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


PHP I18N::scriptDirection方法代码示例

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


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

示例1: spanLtrRtl


//.........这里部分代码省略.........
                                 if (strpos(self::NUMBER_PREFIX, $currentLetter) === false) {
                                     $currentLetter = WT_UTF8_PDF . $currentLetter;
                                 } else {
                                     $currentLetter = $currentLetter . WT_UTF8_PDF;
                                     // Include a trailing + or - in the run
                                 }
                             }
                         }
                     }
                 } else {
                     // If we're outside a numeric string, look for reasons to start it
                     if (strpos(self::NUMBER_PREFIX, $currentLetter) !== false) {
                         // This might be a number lead-in
                         $offset = $currentLen;
                         $nextChar = substr($workingText . "\n", $offset, 1);
                         if (strpos(self::NUMBERS, $nextChar) !== false) {
                             $numberState = true;
                             // We found a digit: the lead-in is therefore numeric
                             if (self::$currentState == 'RTL') {
                                 $currentLetter = WT_UTF8_LRE . $currentLetter;
                             }
                         }
                     } elseif (strpos(self::NUMBERS, $currentLetter) !== false) {
                         $numberState = true;
                         // The current letter is a digit
                         if (self::$currentState == 'RTL') {
                             $currentLetter = WT_UTF8_LRE . $currentLetter;
                         }
                     }
                 }
                 // Determine the directionality of the current UTF-8 character
                 $newState = self::$currentState;
                 while (true) {
                     if (I18N::scriptDirection(I18N::textScript($currentLetter)) === 'rtl') {
                         if (self::$currentState == '') {
                             $newState = 'RTL';
                             break;
                         }
                         if (self::$currentState == 'RTL') {
                             break;
                         }
                         // Switch to RTL only if this isn't a solitary RTL letter
                         $tempText = substr($workingText, $currentLen);
                         while ($tempText != '') {
                             $nextCharArray = self::getChar($tempText, 0);
                             $nextLetter = $nextCharArray['letter'];
                             $nextLen = $nextCharArray['length'];
                             $tempText = substr($tempText, $nextLen);
                             if (I18N::scriptDirection(I18N::textScript($nextLetter)) === 'rtl') {
                                 $newState = 'RTL';
                                 break 2;
                             }
                             if (strpos(self::PUNCTUATION, $nextLetter) !== false || strpos(self::OPEN_PARENTHESES, $nextLetter) !== false) {
                                 $newState = 'RTL';
                                 break 2;
                             }
                             if ($nextLetter === ' ') {
                                 break;
                             }
                             $nextLetter .= substr($tempText . "\n", 0, 5);
                             if ($nextLetter === ' ') {
                                 break;
                             }
                         }
                         // This is a solitary RTL letter : wrap it in UTF8 control codes to force LTR directionality
                         $currentLetter = WT_UTF8_LRO . $currentLetter . WT_UTF8_PDF;
开发者ID:tunandras,项目名称:webtrees,代码行数:67,代码来源:FunctionsRtl.php


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