本文整理汇总了PHP中Thelia\Core\Translation\Translator::addResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::addResource方法的具体用法?PHP Translator::addResource怎么用?PHP Translator::addResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Core\Translation\Translator
的用法示例。
在下文中一共展示了Translator::addResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerValidatorTranslator
public function registerValidatorTranslator(GetResponseEvent $event)
{
/** @var \Thelia\Core\HttpFoundation\Request $request */
$request = $event->getRequest();
$lang = $request->getSession()->getLang();
$vendorFormDir = THELIA_VENDOR . 'symfony' . DS . 'form' . DS . 'Symfony' . DS . 'Component' . DS . 'Form';
$vendorValidatorDir = THELIA_VENDOR . 'symfony' . DS . 'validator' . DS . 'Symfony' . DS . 'Component' . DS . 'Validator';
$this->translator->addResource('xlf', sprintf($vendorFormDir . DS . 'Resources' . DS . 'translations' . DS . 'validators.%s.xlf', $lang->getCode()), $lang->getLocale(), 'validators');
$this->translator->addResource('xlf', sprintf($vendorValidatorDir . DS . 'Resources' . DS . 'translations' . DS . 'validators.%s.xlf', $lang->getCode()), $lang->getLocale(), 'validators');
}
示例2: initLocales
/**
* @param InputInterface $input
* @return array
*/
protected function initLocales(InputInterface $input)
{
$this->locales = [];
$availableLocales = [];
$finder = Finder::create()->name('*.php')->depth(0)->sortByName()->in(THELIA_SETUP_DIRECTORY . 'I18n');
// limit to only some locale(s)
$localesToKeep = $input->getOption("locales");
if (!empty($localesToKeep)) {
$localesToKeep = explode(',', $localesToKeep);
} else {
$localesToKeep = null;
}
/** @var \SplFileInfo $file */
foreach ($finder as $file) {
$locale = $file->getBasename('.php');
$availableLocales[] = $locale;
if (empty($localesToKeep) || in_array($locale, $localesToKeep)) {
$this->locales[] = $locale;
$this->translator->addResource('php', $file->getRealPath(), $locale, 'install');
}
}
if (empty($this->locales)) {
throw new \RuntimeException(sprintf("You should at least generate sql for one locale. Available locales : %s", implode(', ', $availableLocales)));
}
}