Skip to content

Commit

Permalink
add hack to accomodate github based language packs
Browse files Browse the repository at this point in the history
  • Loading branch information
gregrgay committed Dec 16, 2017
1 parent 25b8b78 commit 2eb8a58
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions mods/_core/languages/classes/LanguageManager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,27 @@ function exists($code, $locale = '') {
// import language pack from specified file
function import($filename) {
global $languageManager, $msg;

require_once(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
if(strstr($_FILES['file']['name'], 'master')){
// hack to create path to subdir for imported github language packs
// no idea why this is happening with github zip files
$import_dir = str_replace(".zip", "", $_FILES['file']['name']);
}
require_once(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
require_once(AT_INCLUDE_PATH.'../mods/_core/languages/classes/LanguagesParser.class.php');

$import_path = AT_CONTENT_DIR . 'import/';

if(isset($import_dir)){
// hack to create path to subdir for imported github language packs
$import_path = AT_CONTENT_DIR . 'import/'.$import_dir.'/';
} else{
$import_path = AT_CONTENT_DIR . 'import/';
}
$language_xml = @file_get_contents($import_path.'language.xml');
$archive = new PclZip($filename);

if ($archive->extract( PCLZIP_OPT_PATH, $import_path) == 0) {
exit('Error : ' . $archive->errorInfo(true));
}

$language_xml = @file_get_contents($import_path.'language.xml');

$languageParser = new LanguageParser();
$languageParser->parse($language_xml);
$languageEditor = $languageParser->getLanguageEditor(0);
Expand All @@ -305,7 +313,7 @@ function import($filename) {
}

if (!$msg->containsErrors()) {
$languageEditor->import($import_path . 'language_text.sql');
$languageEditor->import($import_path . 'language_text.sql');
$msg->addFeedback('IMPORT_LANG_SUCCESS');
}

Expand Down

0 comments on commit 2eb8a58

Please sign in to comment.