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


PHP Translator::getLoader方法代码示例

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


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

示例1: handle

 /**
  * Execute the command.
  *
  * @param Filesystem $fileSystem
  * @param Application $app
  * @param Translator $translator
  * @param TranslationRepositoryInterface $repository
  * @param Dispatcher $event
  */
 public function handle(Filesystem $fileSystem, Application $app, Translator $translator, TranslationRepositoryInterface $repository, Dispatcher $event)
 {
     $files = $fileSystem->allFiles($app->langPath());
     $loader = $translator->getLoader();
     /** @var Collection $groups */
     $groups = $this->dispatch(new ImportGroupsCommand());
     /** @var Collection $languages */
     $languages = $this->dispatch(new ImportLanguagesCommand());
     foreach ($files as $file) {
         /** @var Language $language */
         $language = $languages->where('name', $file->getRelativePath())->first();
         /** @var Group $group */
         $group = $groups->where('name', pathinfo($file)['filename'])->first();
         /** @var Collection $translations */
         $translations = collect($loader->load($language->name, $group->name));
         /**
          * Convert all arrays to to json
          */
         $translations->transform(function ($value) {
             return is_array($value) ? json_encode($value) : $value;
         });
         /**
          * Merge Translations on the database with local translations
          */
         $model = $repository->fetch($language->id, $group->id);
         $database = $model->lists('value', 'key');
         /**
          * If translations is an array, process the JSON data and update it
          */
         $translations->each(function ($data, $key) use($database, $model) {
             /**
              * If it's not a json then there is nothing to update
              */
             if ($model->isEmpty() or !$this->isJSON($data)) {
                 return;
             }
             /**
              * Retrieve Json
              */
             $decoded = $database->map(function ($value) {
                 return json_decode($value, true);
             });
             $value = collect(json_decode($data, true))->merge($decoded->get($key))->toJson();
             /**
              * Update Translation
              */
             $updateCommand = new UpdateTranslationCommand($model->where('key', $key)->first()->id, compact('value'));
             $this->dispatch($updateCommand);
         });
         /**
          * First get only new values that are not already on the DB
          * Then for each save new Translation on DB
          * Save Translations on database
          */
         $newItems = $translations->merge($database)->diff($database)->map(function ($value, $key) use($language, $group) {
             return $this->dispatch(new CreateTranslationCommand($language->id, $group->id, compact('key', 'value')));
         });
         /**
          * Announce Translations was created
          */
         if (!$newItems->isEmpty()) {
             $event->fire(new TranslationsWasCreated($newItems));
         }
     }
 }
开发者ID:SkysoulDesign,项目名称:TempArk,代码行数:74,代码来源:ImportTranslationCommand.php

示例2: getLoader

 /**
  * Get the language line loader implementation.
  *
  * @return \Illuminate\Translation\LoaderInterface 
  * @static 
  */
 public static function getLoader()
 {
     return \Illuminate\Translation\Translator::getLoader();
 }
开发者ID:satriashp,项目名称:tour,代码行数:10,代码来源:_ide_helper.php

示例3: getLanguageFile

 private function getLanguageFile($locale, $page)
 {
     return $this->translator->getLoader()->load($locale, $page);
 }
开发者ID:bgies,项目名称:translation-manager-laravel,代码行数:4,代码来源:TranslationEditorController.php


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