Modules\Doptor\TranslationManager\Services\LanguageService::installLanguageFile PHP Method

installLanguageFile() public method

public installLanguageFile ( $file )
    public function installLanguageFile($file)
    {
        $filename = $this->uploadLanguageFile($file);
        $filename = str_replace('.ZIP', '.zip', $filename);
        $canonical = str_replace('.zip', '', $filename);
        $temp_import_path = temp_path() . '/translations_import/' . $canonical . '/';
        if (File::exists($temp_import_path)) {
            File::deleteDirectory($temp_import_path);
        }
        $unzipSuccess = Unzip("{$this->temp_path}{$filename}", $temp_import_path);
        if (!$unzipSuccess) {
            throw new Exception("The language file {$filename} couldn\\'t be extracted.");
        }
        if (!File::exists("{$temp_import_path}language.json")) {
            throw new Exception('language.json doesn\'t exist in the language file');
        }
        $language_config = json_decode(file_get_contents("{$temp_import_path}/language.json"), true);
        $language_dir = $this->language_path . $language_config['code'];
        File::copyDirectory($temp_import_path . 'lang', $language_dir);
        // Import the translations from file to database
        $this->translation_manager->importTranslations();
        return $language_config;
    }