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


PHP Translations::toMoString方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $filesystem = new Filesystem();
     $locator = $container->get("agit.common.filecollector");
     $bundles = $container->getParameter("kernel.bundles");
     $catalogPath = $container->getParameter("kernel.root_dir") . "/{$this->catalogSubdir}";
     $this->getContainer()->get("event_dispatcher")->dispatch("agit.intl.global.translations", new TranslationsEvent($this));
     foreach ($container->getParameter("agit.intl.locales") as $locale) {
         $catalog = new Translations();
         $messagesPath = "{$catalogPath}/{$locale}/LC_MESSAGES";
         $catalogFile = "{$messagesPath}/agit.po";
         $oldCatalog = $filesystem->exists($catalogFile) ? Translations::fromPoFile($catalogFile) : new Translations();
         foreach ($oldCatalog as $translation) {
             $translation->deleteReferences();
         }
         $catalog->mergeWith($oldCatalog, 0);
         foreach ($bundles as $alias => $namespace) {
             $bundlePath = $locator->resolve($alias);
             $bundleCatalogFile = "{$bundlePath}/{$this->catalogSubdir}/bundle.{$locale}.po";
             $bundleCatalog = $filesystem->exists($bundleCatalogFile) ? Translations::fromPoFile($bundleCatalogFile) : new Translations();
             $catalog->mergeWith($bundleCatalog, Merge::ADD);
         }
         if (isset($this->extraTranslations[$locale])) {
             foreach ($this->extraTranslations[$locale] as $translation) {
                 $catalog[] = $translation;
             }
         }
         // NOTE: we delete all headers and only set language in order to avoid garbage commits
         $catalog->deleteHeaders();
         $catalog->setLanguage($locale);
         $catalog->setHeader("Content-Type", "text/plain; charset=UTF-8");
         $filesystem->dumpFile($catalogFile, $catalog->toPoString());
         $filesystem->dumpFile("{$messagesPath}/agit.mo", $catalog->toMoString());
     }
 }
开发者ID:agitation,项目名称:intl-bundle,代码行数:36,代码来源:GlobalCatalogCommand.php


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