mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 19:41:54 +00:00
Show an error if no language files found during setup, mitigates #380
This commit is contained in:
parent
dc7b5b14d5
commit
11e0387e19
@ -34,21 +34,29 @@ class BaseLang{
|
|||||||
$path = \pocketmine\PATH . "src/pocketmine/lang/locale/";
|
$path = \pocketmine\PATH . "src/pocketmine/lang/locale/";
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = array_filter(scandir($path), function($filename){
|
if(is_dir($path)){
|
||||||
return substr($filename, -4) === ".ini";
|
$allFiles = scandir($path);
|
||||||
});
|
|
||||||
|
|
||||||
$result = [];
|
if($allFiles !== false){
|
||||||
|
$files = array_filter($allFiles, function($filename){
|
||||||
|
return substr($filename, -4) === ".ini";
|
||||||
|
});
|
||||||
|
|
||||||
foreach($files as $file){
|
$result = [];
|
||||||
$strings = [];
|
|
||||||
self::loadLang($path . $file, $strings);
|
foreach($files as $file){
|
||||||
if(isset($strings["language.name"])){
|
$strings = [];
|
||||||
$result[substr($file, 0, -4)] = $strings["language.name"];
|
self::loadLang($path . $file, $strings);
|
||||||
|
if(isset($strings["language.name"])){
|
||||||
|
$result[substr($file, 0, -4)] = $strings["language.name"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $langName;
|
protected $langName;
|
||||||
|
@ -45,8 +45,14 @@ class SetupWizard{
|
|||||||
|
|
||||||
public function run(){
|
public function run(){
|
||||||
echo "[*] PocketMine-MP set-up wizard\n";
|
echo "[*] PocketMine-MP set-up wizard\n";
|
||||||
echo "[*] Please select a language:\n";
|
|
||||||
$langs = BaseLang::getLanguageList();
|
$langs = BaseLang::getLanguageList();
|
||||||
|
if(empty($langs)){
|
||||||
|
echo "[!] No language files found, please use provided builds or clone the repository recursively." . PHP_EOL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "[*] Please select a language:\n";
|
||||||
foreach($langs as $short => $native){
|
foreach($langs as $short => $native){
|
||||||
echo " $native => $short\n";
|
echo " $native => $short\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user