setLocale() public method

public setLocale ( string $locale )
$locale string
Ejemplo n.º 1
0
 /**
  * Creates a configuration container and checks the required fields
  *
  * @param array $config
  * @return ConfigModel
  * @throws RequiredConfigurationKeyException
  */
 protected function generateFromArray(array $config)
 {
     $requiredKeys = ['locale', 'fallback-locale', 'encoding'];
     foreach ($requiredKeys as $key) {
         if (!array_key_exists($key, $config)) {
             throw new RequiredConfigurationKeyException(sprintf('Unconfigured required value: %s', $key));
         }
     }
     $container = new ConfigModel();
     $id = isset($config['session-identifier']) ? $config['session-identifier'] : 'laravel-gettext-locale';
     $adapter = isset($config['adapter']) ? $config['adapter'] : \Xinax\LaravelGettext\Adapters\LaravelAdapter::class;
     $container->setLocale($config['locale'])->setSessionIdentifier($id)->setEncoding($config['encoding'])->setCategories(array_get('categories', $config, ['LC_ALL']))->setFallbackLocale($config['fallback-locale'])->setSupportedLocales($config['supported-locales'])->setDomain($config['domain'])->setTranslationsPath($config['translations-path'])->setProject($config['project'])->setTranslator($config['translator'])->setSourcePaths($config['source-paths'])->setSyncLaravel($config['sync-laravel'])->setAdapter($adapter);
     if (array_key_exists('relative-path', $config)) {
         $container->setRelativePath($config['relative-path']);
     }
     if (array_key_exists("custom-locale", $config)) {
         $container->setCustomLocale($config['custom-locale']);
     }
     if (array_key_exists("keywords-list", $config)) {
         $container->setKeywordsList($config['keywords-list']);
     }
     if (array_key_exists("handler", $config)) {
         $container->setHandler($config['handler']);
     }
     return $container;
 }
Ejemplo n.º 2
0
 /**
  * Creates the configuration container and 
  * checks from required fields
  */
 protected function generateFromArray(array $config)
 {
     $requiredKeys = array('locale', 'fallback-locale', 'encoding');
     foreach ($requiredKeys as $key) {
         if (!array_key_exists($key, $config)) {
             throw new RequiredConfigurationKeyException("Unconfigured required value: {$key}");
         }
     }
     $container = new Models\Config();
     $container->setLocale($config['locale'])->setEncoding($config['encoding'])->setFallbackLocale($config['fallback-locale'])->setSupportedLocales($config['supported-locales'])->setDomain($config['domain'])->setTranslationsPath($config['translations-path'])->setProject($config['project'])->setTranslator($config['translator'])->setSourcePaths($config['source-paths'])->setSyncLaravel($config['sync-laravel']);
     return $container;
 }
 /**
  * Creates a configuration container and checks the required fields
  *
  * @param array $config
  * @return ConfigModel
  * @throws RequiredConfigurationKeyException
  */
 protected function generateFromArray(array $config)
 {
     $requiredKeys = ['locale', 'fallback-locale', 'encoding'];
     foreach ($requiredKeys as $key) {
         if (!array_key_exists($key, $config)) {
             throw new RequiredConfigurationKeyException(sprintf('Unconfigured required value: %s', $key));
         }
     }
     $container = new ConfigModel();
     $id = isset($config['session-identifier']) ? $config['session-identifier'] : 'laravel-gettext-locale';
     $container->setLocale($config['locale'])->setSessionIdentifier($id)->setEncoding($config['encoding'])->setFallbackLocale($config['fallback-locale'])->setSupportedLocales($config['supported-locales'])->setDomain($config['domain'])->setTranslationsPath($config['translations-path'])->setProject($config['project'])->setTranslator($config['translator'])->setSourcePaths($config['source-paths'])->setSyncLaravel($config['sync-laravel'])->setRelativePath($config['relativePath']);
     return $container;
 }