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


PHP Translator::setFallback方法代码示例

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


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

示例1: __construct

 /**
  * Create a new translator instance.
  * @param  \Illuminate\Translation\LoaderInterface  $loader
  * @param  string  $locale
  * @param  \Illuminate\Filesystem\Filesystem  $files
  * @return void
  */
 public function __construct(LoaderInterface $loader, $locale, $fallbackLocale, Filesystem $files)
 {
     parent::__construct($loader, $locale);
     parent::setFallback($fallbackLocale);
     $appLoader = new FileLoader($files, app_path() . '/lang');
     $this->appTranslator = new IlluminateTranslator($appLoader, $locale);
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:14,代码来源:Translator.php

示例2: setupTranslator

 /**
  * Setup the translator instance.
  *
  * @param string $fallbackLocale
  * @param string $path
  * @return void
  */
 protected function setupTranslator($fallbackLocale, $path)
 {
     $file = new Filesystem();
     $loader = new FileLoader($file, $path);
     $trans = new Translator($loader, $this->container['config']['app.locale']);
     $trans->setFallback($fallbackLocale);
     $this->translator = $trans;
 }
开发者ID:davinder17s,项目名称:turbo,代码行数:15,代码来源:manager.php

示例3: register

 /**
  * Register any translation services.
  *
  * @param  \Pimple\Container $container
  */
 public function register(Container $container)
 {
     $this->registerLoader($container);
     $container['translator'] = function () use($container) {
         $config = $container['config'];
         $translator = new Translator($container['translation.loader'], $config['app.locale']);
         $translator->setFallback($config['app.fallback_locale']);
         return $translator;
     };
 }
开发者ID:bvqbao,项目名称:app-skeleton,代码行数:15,代码来源:TranslationServiceProvider.php

示例4: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->registerLoader();
     $this->app->singleton('translator', function ($app) {
         $loader = $app['translation.loader'];
         // When registering the translator component, we'll need to set the default
         // locale as well as the fallback locale. So, we'll grab the application
         // configuration so we can easily get both of these values from there.
         $locale = $app['config']['app.locale'];
         $trans = new Translator($loader, $locale);
         $trans->setFallback($app['config']['app.fallback_locale']);
         return $trans;
     });
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:19,代码来源:TranslationServiceProvider.php

示例5: handle

 /**
  * Handle the command.
  *
  * @param Repository  $config
  * @param Application $application
  */
 public function handle(Repository $config, Application $application)
 {
     // First trigger to resolve.
     $application->make('translator');
     /*
      * Change the lang loader so we can
      * add a few more necessary override
      * paths to the API.
      */
     $application->singleton('translation.loader', function ($application) {
         return new Loader($application['files'], $application['path.lang']);
     });
     /*
      * Re-bind the translator so we can use
      * the new loader defined above.
      */
     $application->singleton('translator', function ($application) {
         $loader = $application->make('translation.loader');
         // When registering the translator component, we'll need to set the default
         // locale as well as the fallback locale. So, we'll grab the application
         // configuration so we can easily get both of these values from there.
         $locale = $application['config']['app.locale'];
         $trans = new Translator($loader, $locale);
         $trans->setFallback($application['config']['app.fallback_locale']);
         return $trans;
     });
     /*
      * Set the locale if LOCALE is defined.
      *
      * LOCALE is defined first thing in our
      * HTTP Kernel. Respect it!
      */
     if (defined('LOCALE')) {
         $application->setLocale(LOCALE);
         $config->set('app.locale', LOCALE);
     }
     // Set our locale namespace.
     $application->make('translator')->addNamespace('streams', realpath(__DIR__ . '/../../../resources/lang'));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:45,代码来源:ConfigureTranslator.php

示例6: setFallback

 /**
  * Set the fallback locale being used.
  *
  * @param string $fallback
  * @return void 
  * @static 
  */
 public static function setFallback($fallback)
 {
     \Illuminate\Translation\Translator::setFallback($fallback);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例7: registerPaths

 /**
  * Register all available paths into the laravel system
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  * @return Directory
  */
 public function registerPaths($app)
 {
     // only register if tenant directory exists
     if ($this->base()) {
         /*
          * critical priority, load vendors
          */
         if ($this->vendor() && File::exists($this->vendor() . 'autoload.php')) {
             File::requireOnce($this->vendor() . 'autoload.php');
         }
         /*
          * highest priority, load service providers; or possible custom code before any other include from tenant
          */
         if ($this->providers() && File::exists($this->providers())) {
             File::requireOnce($this->providers());
         }
         /*
          * mediocre priority, load additional config files
          */
         if ($this->config() && File::isDirectory($this->config())) {
             foreach (File::allFiles($this->config()) as $path) {
                 $key = File::name($path);
                 $app['config']->set($key, array_merge(require $path, $app['config']->get($key, [])));
             }
         }
         /*
          * lowest priority load view directory
          */
         if ($this->views() && File::isDirectory($this->views())) {
             $app['view']->addLocation($this->views());
         }
         // set cache
         if (File::isDirectory($this->cache())) {
             $app['config']->set('cache.prefix', "{$app['config']->get('cache.prefix')}-{$this->website->id}");
         }
         // @TODO we really can't use cache yet for application cache
         // replaces lang directory
         if ($this->lang() && File::isDirectory($this->lang())) {
             $path = $this->lang();
             $app->bindShared('translation.loader', function ($app) use($path) {
                 return new FileLoader($app['files'], $path);
             });
             $app->bindShared('translator', function ($app) {
                 $translator = new Translator($app['translation.loader'], $app['config']['app.locale']);
                 $translator->setFallback($app['config']['app.fallback_locale']);
                 return $translator;
             });
         }
         // identify a possible routes.php file
         if ($this->routes() && File::exists($this->routes())) {
             File::requireOnce($this->routes());
         }
     }
     return $this;
 }
开发者ID:rpeterson,项目名称:multi-tenant,代码行数:61,代码来源:Directory.php

示例8: setFallback

 /**
  * Set the fallback locale being used.
  *
  * @param  string $fallback
  *
  * @return void
  */
 public function setFallback($fallback)
 {
     //$this->fallback = $fallback;
     parent::setFallback($fallback);
 }
开发者ID:vsch,项目名称:laravel-translation-manager,代码行数:12,代码来源:Translator.php

示例9: registerLangRepository

 protected function registerLangRepository()
 {
     $config = $this->get('config');
     if ($config->get('lang.use_wordpress')) {
         add_action('plugins_loaded', function () use($config) {
             load_plugin_textdomain($config->get('app.plugin_prefix'), false, $config->get('lang.lang_path'));
         });
         return;
     }
     // if
     $loader = new FileLoader(new Filesystem(), $config->get('lang.lang_path'));
     $translator = new Translator($loader, get_locale());
     $translator->setFallback($config->get('lang.fallback_locale'));
     $this->instance('lang', $translator);
 }
开发者ID:Whyounes,项目名称:WP-KAYO,代码行数:15,代码来源:Application.php


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