0

代码:

   $app->register(new Silex\Provider\TranslationServiceProvider(), array(
      'locale' => 'sr_Latn',
      'translation.class_path' => __DIR__ . '/../vendor/symfony/src',
      'translator.messages' => array('sr_Latn' => __DIR__ .'/../vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.sr_Latn.xlf')
    ));
    $app['translator.loader'] = new Symfony\Component\Translation\Loader\XliffFileLoader();

我仍然收到英文的验证消息。任何的想法?

4

1 回答 1

1

您需要添加一个调用Translator::addResource

$file = __DIR__ .'/../vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.sr_Latn.xlf';
$app['translator']->addResource('xliff', $file, 'sr_Latn', 'validators');

另请参阅Symfony\Bundle\FrameworkBundle\DependencyInjection::registerTranslatorConfiguration

于 2012-02-16T13:32:02.530 回答