public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->allFiles($langPath) as $file) {
             $group = $file->getRelativePathname();
             $group = str_replace('.' . $this->files->extension($group), '', $group);
             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;
 }
 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->make('path') . '/lang') 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 = array_dot(\Lang::getLoader()->load($locale, $group));
             foreach ($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;
 }
 public function postEdit(Request $request, $group, $sub_group = null)
 {
     if (!in_array($group, $this->manager->getConfig('exclude_groups'))) {
         $name = $request->get('name');
         $value = $request->get('value');
         list($locale, $key) = explode('|', $name, 2);
         $translation = Translation::firstOrNew(['locale' => $locale, 'group' => $sub_group ? $group . "/" . $sub_group : $group, 'key' => $key]);
         $translation->value = (string) $value ?: null;
         $translation->status = Translation::STATUS_CHANGED;
         $translation->save();
         return array('status' => 'ok');
     }
 }
 public function postEdit($group)
 {
     if (!in_array($group, $this->manager->getConfig('exclude_groups'))) {
         $name = Input::get('name');
         $value = Input::get('value');
         list($locale, $key) = explode('|', $name, 2);
         $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
         $translation->value = (string) $value ?: null;
         $translation->status = Translation::STATUS_CHANGED;
         $translation->save();
         return array('status' => 'ok');
     }
 }
 public function postEdit(Request $request, $group)
 {
     if (!in_array($group, $this->manager->getConfig('exclude_groups'))) {
         $groups = func_get_args();
         array_shift($groups);
         // remove the $request
         $group = implode('/', $groups);
         $name = $request->get('name');
         $value = $request->get('value');
         list($locale, $key) = explode('|', $name, 2);
         $translation = Translation::firstOrNew(['locale' => $locale, 'group' => $group, 'key' => $key]);
         $translation->value = (string) $value ?: null;
         $translation->status = Translation::STATUS_CHANGED;
         $translation->save();
         return array('status' => 'ok');
     }
 }
 public function importTranslations($replace = false)
 {
     $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;
             }
             $subLangPath = str_replace($langPath . DIRECTORY_SEPARATOR, "", $info['dirname']);
             if ($subLangPath != $langPath) {
                 $group = $subLangPath . "/" . $group;
             }
             $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(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;
 }
 public function importTranslations($replace = false)
 {
     $dirs = $this->getDirectories();
     $counter = 0;
     foreach ($dirs as $langPath) {
         $namespace = null;
         if (strpos($langPath, 'Modules')) {
             $namespace = strtolower(basename(dirname(dirname($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, $namespace);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $namespace ? $namespace . '::' . $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;
 }