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


PHP Translator::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Override Symfony\Component\Translation\Translator to lazy load every catalogs from:
  *     - BackBee\Resources\translations
  *     - PATH_TO_REPOSITORY\Resources\translations
  *     - PATH_TO_CONTEXT_REPOSITORY\Resources\translations.
  *
  * @param BBApplication $application
  * @param string        $locale
  */
 public function __construct(BBApplication $application, $locale)
 {
     parent::__construct($locale);
     // retrieve default fallback from container and set it
     $fallback = $application->getContainer()->getParameter('translator.fallback');
     $this->setFallbackLocales([$fallback]);
     // xliff is recommended by Symfony so we register its loader as default one
     $this->addLoader('xliff', new XliffFileLoader());
     // define in which directory we should looking at to find xliff files
     $dirToLookingAt = array($application->getBBDir() . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'translations', $application->getRepository() . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'translations');
     if ($application->getRepository() !== $application->getBaseRepository()) {
         $dirToLookingAt[] = $application->getBaseRepository() . 'Resources' . DIRECTORY_SEPARATOR . 'translations';
     }
     // loop in every directory we should looking at and load catalog from file which match to the pattern
     foreach ($dirToLookingAt as $dir) {
         if (true === is_dir($dir)) {
             foreach (scandir($dir) as $filename) {
                 preg_match('/(.+)\\.(.+)\\.xlf$/', $filename, $matches);
                 if (0 < count($matches)) {
                     $this->addResource('xliff', $dir . DIRECTORY_SEPARATOR . $filename, $matches[2], $matches[1]);
                 }
             }
         }
     }
 }
开发者ID:gobjila,项目名称:BackBee,代码行数:34,代码来源:Translator.php

示例2: __construct

 /**
  * @param IUserLocaleResolver $localeResolver
  * @param MessageSelector $selector The message selector for pluralization
  * @param CatalogueCompiler $catalogueCompiler
  * @param FallbackResolver $fallbackResolver
  * @param IResourceLoader $loader
  */
 public function __construct(IUserLocaleResolver $localeResolver, MessageSelector $selector, CatalogueCompiler $catalogueCompiler, FallbackResolver $fallbackResolver, IResourceLoader $loader)
 {
     $this->localeResolver = $localeResolver;
     $this->catalogueCompiler = $catalogueCompiler;
     $this->fallbackResolver = $fallbackResolver;
     $this->translationsLoader = $loader;
     parent::__construct(NULL, $selector);
 }
开发者ID:rattuscz,项目名称:Translation,代码行数:15,代码来源:Translator.php

示例3: __construct

 public function __construct($config = [])
 {
     foreach ($config as $name => $value) {
         $this->{$name} = $value;
     }
     parent::__construct($this->defaultLocale, null, $this->cacheDir, $this->debug);
     $this->init();
 }
开发者ID:bixuehujin,项目名称:blink-i18n,代码行数:8,代码来源:Translator.php

示例4: __construct

 public function __construct(ServiceContainer $service, $locale)
 {
     parent::__construct($locale);
     $this->service = $service;
     $dispatcher = $service->getDispatcher();
     $dispatcher->addSubscriber($this);
     $this->domainStack = new Stack();
 }
开发者ID:keeko,项目名称:framework,代码行数:8,代码来源:KeekoTranslator.php

示例5: __construct

 /**
  * @param ContainerInterface $container
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     // Allow singleton style calls once intanciated.
     // For this to work, the Translator service has to be instanciated very early. This is done manually
     // in TheliaHttpKernel, by calling $this->container->get('thelia.translator');
     parent::__construct(null);
     self::$instance = $this;
 }
开发者ID:badelas,项目名称:thelia,代码行数:12,代码来源:Translator.php

示例6: __construct

 /**
  * @param IUserLocaleResolver $localeResolver
  * @param MessageSelector $selector The message selector for pluralization
  * @param CatalogueCompiler $catalogueCompiler
  * @param FallbackResolver $fallbackResolver
  * @param IResourceLoader $loader
  */
 public function __construct(IUserLocaleResolver $localeResolver, MessageSelector $selector, CatalogueCompiler $catalogueCompiler, FallbackResolver $fallbackResolver, IResourceLoader $loader, ILogger $tracyLogger = null, LoggerInterface $psrLogger = null)
 {
     $this->localeResolver = $localeResolver;
     $this->catalogueCompiler = $catalogueCompiler;
     $this->fallbackResolver = $fallbackResolver;
     $this->translationsLoader = $loader;
     $this->logger = $psrLogger ?: $tracyLogger;
     parent::__construct(NULL, $selector);
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:16,代码来源:Translator.php

示例7: __construct

 public function __construct($config = array())
 {
     // @TODO: needs to be more configurable
     parent::__construct($config['fallback']);
     $this->addLoader('xlf', new XliffFileLoader());
     foreach ($config['resources'] as $resource) {
         extract($resource);
         $this->addResource($format, $resource, $locale, $domain);
     }
 }
开发者ID:renegare,项目名称:skip_php_framework,代码行数:10,代码来源:TranslatorService.php

示例8: __construct

 /**
  * @param TranslatorLoaderProviderInterface $loaderProvider
  * @param TranslatorResourceProviderInterface $resourceProvider
  * @param MessageSelector $messageSelector
  * @param string $locale
  * @param array $options
  */
 public function __construct(TranslatorLoaderProviderInterface $loaderProvider, TranslatorResourceProviderInterface $resourceProvider, MessageSelector $messageSelector, $locale, array $options = [])
 {
     $this->assertOptionsAreKnown($options);
     $this->loaderProvider = $loaderProvider;
     $this->resourceProvider = $resourceProvider;
     $this->options = array_merge($this->options, $options);
     if (null !== $this->options['cache_dir'] && $this->options['debug']) {
         $this->addResources();
     }
     parent::__construct($locale, $messageSelector, $this->options['cache_dir'], $this->options['debug']);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:18,代码来源:Translator.php

示例9: __construct

 /**
  * Constructor.
  *
  * Available options:
  *
  *   * cache_dir: The cache directory (or null to disable caching)
  *   * debug:     Whether to enable debugging or not (false by default)
  *
  * @param ContainerInterface $container A ContainerInterface instance
  * @param MessageSelector    $selector  The message selector for pluralization
  * @param array              $loaderIds An array of loader Ids
  * @param array              $options   An array of options
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array())
 {
     $this->container = $container;
     $this->loaderIds = $loaderIds;
     // check option names
     if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
         throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
     }
     $this->options = array_merge($this->options, $options);
     parent::__construct(null, $selector);
 }
开发者ID:JoseGMaestre,项目名称:Cupon_check,代码行数:26,代码来源:Translator.php

示例10: __construct

 /**
  * Constructor.
  *
  * Available options:
  *
  *   * cache_dir: The cache directory (or null to disable caching)
  *   * debug:     Whether to enable debugging or not (false by default)
  *
  * @param ContainerInterface $container A ContainerInterface instance
  * @param MessageSelector    $selector  The message selector for pluralization
  * @param array              $options   An array of options
  * @param Session            $session   A Session instance
  */
 public function __construct(ContainerInterface $container, MessageSelector $selector, array $options = array(), Session $session = null)
 {
     parent::__construct(null, $selector);
     $this->session = $session;
     $this->container = $container;
     $this->options = array('cache_dir' => null, 'debug' => false);
     // check option names
     if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
         throw new \InvalidArgumentException(sprintf('The Router does not support the following options: \'%s\'.', implode('\', \'', $diff)));
     }
     $this->options = array_merge($this->options, $options);
 }
开发者ID:notbrain,项目名称:symfony,代码行数:25,代码来源:Translator.php

示例11: __construct

 /**
  * Constructor.
  *
  * Available options:
  *
  *   * cache_dir: The cache directory (or null to disable caching)
  *   * debug:     Whether to enable debugging or not (false by default)
  *   * resource_files: List of translation resources available grouped by locale.
  *
  * @param ContainerInterface $container A ContainerInterface instance
  * @param MessageSelector    $selector  The message selector for pluralization
  * @param array              $loaderIds An array of loader Ids
  * @param array              $options   An array of options
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array())
 {
     $this->container = $container;
     $this->loaderIds = $loaderIds;
     // check option names
     if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
         throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
     }
     $this->options = array_merge($this->options, $options);
     $this->resourceLocales = array_keys($this->options['resource_files']);
     if (null !== $this->options['cache_dir'] && $this->options['debug']) {
         $this->loadResources();
     }
     parent::__construct($container->getParameter('kernel.default_locale'), $selector, $this->options['cache_dir'], $this->options['debug']);
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:31,代码来源:Translator.php

示例12: __construct

 public function __construct(Container $app, MessageSelector $selector)
 {
     $this->app = $app;
     // TODO implementar o cache_dir e o debug
     parent::__construct(null, $selector);
 }
开发者ID:brodaproject,项目名称:broda,代码行数:6,代码来源:Translator.php

示例13: __construct

 public function __construct(Application $app, MessageSelector $selector)
 {
     $this->app = $app;
     parent::__construct(null, $selector);
 }
开发者ID:silvioneto,项目名称:ondealmocar,代码行数:5,代码来源:Translator.php

示例14: __construct

 public function __construct(array $config)
 {
     $this->config = $config;
     parent::__construct($GLOBALS['TL_LANGUAGE']);
     $this->setFallbackLocales(array('en'));
 }
开发者ID:contaoblackforest,项目名称:contao-symfony-component-form,代码行数:6,代码来源:Translator.php

示例15: __construct

 public function __construct(Application $app, MessageSelector $selector, $cacheDir = null, $debug = false)
 {
     $this->app = $app;
     parent::__construct(null, $selector, $cacheDir, $debug);
 }
开发者ID:shomimn,项目名称:builder,代码行数:5,代码来源:Translator.php


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