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


PHP Translations::setDomain方法代码示例

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


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

示例1: testAllKnownTranslationFunctionsAreCovered

 /**
  * All known translation functions are covered.
  */
 public function testAllKnownTranslationFunctionsAreCovered()
 {
     $extractor = new WordPressExtractor();
     $translations = new Translations();
     $translations->setDomain('test');
     $translations = $extractor->fromDirectory($this->getResourcesPath() . 'commonSources', $translations);
     // file_put_contents($this->getResourcesPath() . 'commonSources.php', var_export($arrayCopy, true));
     $poContent = $translations->toPoString();
     // strip base path for better comparison
     $poContent = str_replace($this->getResourcesPath(), '', $poContent);
     $this->assertContains('"translate"', $poContent);
     $this->assertContains('"translate_with_gettext_context"', $poContent);
     $this->assertContains('"__"', $poContent);
     $this->assertContains('"_x"', $poContent);
     $this->assertContains('"_e"', $poContent);
     $this->assertContains('"_ex"', $poContent);
     $this->assertContains('"esc_attr__"', $poContent);
     $this->assertContains('"esc_attr_e"', $poContent);
     $this->assertContains('"esc_attr_x"', $poContent);
     $this->assertContains('"esc_html__"', $poContent);
     $this->assertContains('"esc_html_e"', $poContent);
     $this->assertContains('"esc_html_x"', $poContent);
     $this->assertContains('"_n-single"', $poContent);
     $this->assertContains('"_n-plural"', $poContent);
     $this->assertContains('"_nx-context"', $poContent);
     $this->assertContains('"_nx-single"', $poContent);
     $this->assertContains('"_nx-plural"', $poContent);
     $this->assertContains('"_n_noop-singular"', $poContent);
     $this->assertContains('"_n_noop-plural"', $poContent);
     $this->assertContains('"_nx_noop-context"', $poContent);
     $this->assertContains('"_nx_noop-singular"', $poContent);
     $this->assertContains('"_nx_noop-plural"', $poContent);
 }
开发者ID:sourcerer-mike,项目名称:wp-easy-translate,代码行数:36,代码来源:WpFunctionsScanner.php

示例2: handleArray

 /**
  * Handle an array of translations and append to the Translations instance.
  *
  * @param array        $content
  * @param Translations $translations
  */
 public static function handleArray(array $content, Translations $translations)
 {
     $content = current($content);
     $translations_info = isset($content['']) ? $content[''] : null;
     unset($content['']);
     if (isset($translations_info['domain'])) {
         $translations->setDomain($translations_info['domain']);
     }
     foreach ($content as $key => $message) {
         static::insertTranslation($translations, $key, $message);
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:18,代码来源:PhpArray.php

示例3: handleArray

 /**
  * Handle an array of translations and append to the Translations instance
  *
  * @param array        $content
  * @param Translations $translations
  */
 public static function handleArray(array $content, Translations $translations)
 {
     $content = $content['messages'];
     $translations_info = isset($content['']) ? $content[''] : null;
     unset($content['']);
     if (isset($translations_info['domain'])) {
         $translations->setDomain($translations_info['domain']);
     }
     $context_glue = '\\u0004';
     foreach ($content as $key => $message) {
         $key = explode($context_glue, $key);
         $context = isset($key[1]) ? array_shift($key) : '';
         $original = array_shift($key);
         $plural = array_shift($message);
         $translation = array_shift($message);
         $plural_translation = array_shift($message);
         $entry = $translations->insert($context, $original, $plural);
         $entry->setTranslation($translation);
         $entry->setPluralTranslation($plural_translation);
     }
 }
开发者ID:jankal,项目名称:mvc,代码行数:27,代码来源:PhpArray.php

示例4: extract

 /**
  * Handle an array of translations and append to the Translations instance.
  *
  * @param array        $content
  * @param Translations $translations
  */
 public static function extract(array $content, Translations $translations)
 {
     $messages = current($content);
     $headers = isset($messages['']) ? $messages[''] : null;
     unset($messages['']);
     if (!empty($headers['domain'])) {
         $translations->setDomain($headers['domain']);
     }
     if (!empty($headers['lang'])) {
         $translations->setLanguage($headers['lang']);
     }
     if (!empty($headers['plural-forms'])) {
         $translations->setHeader(Translations::HEADER_PLURAL, $headers['plural-forms']);
     }
     $context_glue = '\\u0004';
     foreach ($messages as $key => $translation) {
         $key = explode($context_glue, $key);
         $context = isset($key[1]) ? array_shift($key) : '';
         $translations->insert($context, array_shift($key))->setTranslation(array_shift($translation))->setPluralTranslations($translation);
     }
 }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:27,代码来源:Jed.php

示例5: fromArray

 /**
  * Extract the entries from a multidimensional array.
  * 
  * @param array        $messages
  * @param Translations $translations
  */
 private static function fromArray(array $messages, Translations $translations)
 {
     if (!empty($messages['domain'])) {
         $translations->setDomain($messages['domain']);
     }
     if (!empty($messages['plural-forms'])) {
         $translations->setHeader(Translations::HEADER_PLURAL, $messages['plural-forms']);
     }
     foreach ($messages['messages'] as $context => $contextTranslations) {
         foreach ($contextTranslations as $original => $value) {
             if ($context === '' && $original === '') {
                 self::extractHeaders(is_array($value) ? array_shift($value) : $value, $translations);
                 continue;
             }
             $translation = $translations->insert($context, $original);
             if (is_array($value)) {
                 $translation->setTranslation(array_shift($value));
                 $translation->setPluralTranslations($value);
             } else {
                 $translation->setTranslation($value);
             }
         }
     }
 }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:30,代码来源:MultidimensionalArrayTrait.php


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