public function importTranslations($replace, $groups = null) { // this can come from the command line if (is_array($groups)) { foreach ($groups as &$group) { $group = self::fixGroup($group); } } else { $groups = self::fixGroup($groups); } // if we don't track usage information and replace == 2 we can truncate the translations for the groups or group if (!$this->config(self::LOG_KEY_USAGE_INFO_KEY) && $replace == 2) { $this->truncateTranslations($groups); } $this->imported = 0; $this->clearCache($groups); $this->clearUsageCache(false, $groups); // Laravel 5.1 $pathTemplateResolver = new PathTemplateResolver($this->files, $this->app->basePath(), $this->config('language_dirs'), '5'); // Laravel 4.2 //$pathTemplateResolver = new PathTemplateResolver($this->files, base_path(), $this->config('language_dirs'), '4'); $langFiles = $pathTemplateResolver->langFileList(); if ($groups !== null) { // now we can filter to the list of given groups or $files = []; if (!is_array($groups)) { $groups = array($groups); } $groups = array_combine($groups, $groups); foreach ($langFiles as $file => $values) { if (array_key_exists($values['{db_group}'], $groups)) { $files[$file] = $values; } } $langFiles = $files; } foreach ($langFiles as $langFile => $vars) { $locale = $vars['{locale}']; $db_group = $vars['{db_group}']; if (in_array($db_group, $this->config(self::EXCLUDE_GROUPS_KEY))) { continue; } $translations = array_dot(include $langFile); $this->importTranslationFile($locale, $db_group, $translations, $replace); } return $this->imported; }
public function importTranslations($replace, $groups = null) { $this->imported = 0; $this->clearCache($groups); // Laravel 5.1 $pathTemplateResolver = new PathTemplateResolver($this->files, $this->app->basePath(), $this->config()['language_dirs'], '5'); // Laravel 4.2 //$pathTemplateResolver = new PathTemplateResolver($this->files, base_path(), $this->config()['language_dirs'], '4'); $langFiles = $pathTemplateResolver->langFileList(); if ($groups !== null) { // now we can filter to the list of given groups or $files = []; if (!is_array($groups)) { $groups = array($groups); } $groups = array_combine($groups, $groups); foreach ($langFiles as $file => $values) { if (array_key_exists($values['{db_group}'], $groups)) { $files[$file] = $values; } } $langFiles = $files; } foreach ($langFiles as $langFile => $vars) { $locale = $vars['{locale}']; $db_group = $vars['{db_group}']; if (in_array($db_group, $this->config()['exclude_groups'])) { continue; } $translations = array_dot(include $langFile); $this->importTranslationFile($locale, $db_group, $translations, $replace); } return $this->imported; }