本文整理匯總了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());
}
}