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


PHP Translations::getHeader方法代码示例

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


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

示例1: toArray

 /**
  * Generates an array with the translations.
  *
  * @param Translations $translations
  *
  * @return array
  */
 public static function toArray(Translations $translations)
 {
     $array = array();
     $context_glue = "";
     foreach ($translations as $translation) {
         $key = ($translation->hasContext() ? $translation->getContext() . $context_glue : '') . $translation->getOriginal();
         $entry = array($translation->getPlural(), $translation->getTranslation());
         if ($translation->hasPluralTranslation()) {
             $entry = array_merge($entry, $translation->getPluralTranslation());
         }
         $array[$key] = $entry;
     }
     $domain = $translations->getDomain() ?: 'messages';
     $lang = $translations->getLanguage() ?: 'en';
     $fullArray = array($domain => array('' => array('domain' => $domain, 'lang' => $lang, 'plural-forms' => 'nplurals=2; plural=(n != 1);')));
     if ($translations->getHeader('Plural-Forms') !== null) {
         $fullArray[$domain]['']['plural-forms'] = $translations->getHeader('Plural-Forms');
     }
     $fullArray[$domain] = array_merge($fullArray[$domain], $array);
     return $fullArray;
 }
开发者ID:Marketing1by1,项目名称:Gettext,代码行数:28,代码来源:PhpArray.php

示例2: extractHeaders

 /**
  * Add the headers found to the translations instance.
  * 
  * @param string       $headers
  * @param Translations $translations
  *
  * @return array
  */
 private static function extractHeaders($headers, Translations $translations)
 {
     $headers = explode("\n", $headers);
     $currentHeader = null;
     foreach ($headers as $line) {
         $line = self::convertString($line);
         if ($line === '') {
             continue;
         }
         if (self::isHeaderDefinition($line)) {
             $header = array_map('trim', explode(':', $line, 2));
             $currentHeader = $header[0];
             $translations->setHeader($currentHeader, $header[1]);
         } else {
             $entry = $translations->getHeader($currentHeader);
             $translations->setHeader($currentHeader, $entry . $line);
         }
     }
 }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:27,代码来源:HeadersExtractorTrait.php

示例3: toString

 /**
  * {@parentDoc}.
  */
 public static function toString(Translations $translations, array $options = [])
 {
     $domain = $translations->getDomain() ?: 'messages';
     $options += static::$options;
     return json_encode([$domain => ['' => ['domain' => $domain, 'lang' => $translations->getLanguage() ?: 'en', 'plural-forms' => $translations->getHeader('Plural-Forms') ?: 'nplurals=2; plural=(n != 1);']] + self::buildMessages($translations)], $options['json']);
 }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:9,代码来源:Jed.php


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