getLoader() public static method

Get the language line loader implementation.
public static getLoader ( ) : Illuminate\Translation\LoaderInterface
return Illuminate\Translation\LoaderInterface
 public function read($file)
 {
     $fileinfo = pathinfo($file);
     $filename = $fileinfo['filename'];
     $dirinfo = pathinfo($fileinfo['dirname']);
     $locale = $dirinfo['filename'];
     $content = \Lang::getLoader()->load($locale, $filename);
     return $content;
 }
Exemplo n.º 2
0
 public function getTranslations($catalog)
 {
     $data = array();
     $rootDir = dirname($this->app->make('path'));
     foreach ($this->filesystem->directories($rootDir . '/resources/lang') as $langPath) {
         $locale = basename($langPath);
         $fileName = $langPath . '/' . $catalog . '.php';
         $date = date_create_from_format('U', filemtime($fileName));
         $translations = array_dot(\Lang::getLoader()->load($locale, $catalog));
         foreach ($translations as $key => $value) {
             $data[$key][$locale] = array('message' => $value, 'updatedAt' => $date->format('c'), 'fileName' => $fileName, 'bundle' => $catalog);
         }
     }
     return $data;
 }
 public function importTranslations()
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->allfiles($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             if ($langPath != $info['dirname']) {
                 $group = substr(str_replace($langPath, '', $info['dirname']) . '/' . $info['filename'], 1);
             }
             $g = Group::firstOrNew(array('label' => $group));
             $g->save();
             $l = Locale::firstOrNew(array('label' => $locale));
             $l->save();
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     // process only string values
                     if (is_array($value)) {
                         continue;
                     }
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(['locale_id' => $l->id, 'key' => $key]);
                     $g->translations()->save($translation);
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     $translation->value = $value;
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }
Exemplo n.º 4
-1
 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }