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