當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。