mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Removed InstallerLang mess, language improvements, updated PocketMine-Language submodule
This commit is contained in:
@ -29,6 +29,28 @@ class BaseLang{
|
||||
|
||||
const FALLBACK_LANGUAGE = "eng";
|
||||
|
||||
public static function getLanguageList(string $path = "") : array{
|
||||
if($path === ""){
|
||||
$path = \pocketmine\PATH . "src/pocketmine/lang/locale/";
|
||||
}
|
||||
|
||||
$files = array_filter(scandir($path), function($filename){
|
||||
return substr($filename, -4) === ".ini";
|
||||
});
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach($files as $file){
|
||||
$strings = [];
|
||||
self::loadLang($path . $file, $strings);
|
||||
if(isset($strings["language.name"])){
|
||||
$result[substr($file, 0, -4)] = $strings["language.name"];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected $langName;
|
||||
|
||||
protected $lang = [];
|
||||
@ -42,10 +64,10 @@ class BaseLang{
|
||||
$path = \pocketmine\PATH . "src/pocketmine/lang/locale/";
|
||||
}
|
||||
|
||||
if(!$this->loadLang($file = $path . $this->langName . ".ini", $this->lang)){
|
||||
if(!self::loadLang($file = $path . $this->langName . ".ini", $this->lang)){
|
||||
MainLogger::getLogger()->error("Missing required language file $file");
|
||||
}
|
||||
if(!$this->loadLang($file = $path . $fallback . ".ini", $this->fallbackLang)){
|
||||
if(!self::loadLang($file = $path . $fallback . ".ini", $this->fallbackLang)){
|
||||
MainLogger::getLogger()->error("Missing required language file $file");
|
||||
}
|
||||
}
|
||||
@ -58,7 +80,7 @@ class BaseLang{
|
||||
return $this->langName;
|
||||
}
|
||||
|
||||
protected function loadLang($path, array &$d){
|
||||
protected static function loadLang($path, array &$d){
|
||||
if(file_exists($path)){
|
||||
if(strlen($content = file_get_contents($path)) > 0){
|
||||
foreach(explode("\n", $content) as $line){
|
||||
|
Reference in New Issue
Block a user