Skip to content

Commit

Permalink
api: fix some languages are unavailable to set in-game
Browse files Browse the repository at this point in the history
  • Loading branch information
onebone committed Apr 11, 2021
1 parent d45f577 commit b61fab9
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions EconomyAPI/src/onebone/economyapi/EconomyAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,8 @@ class EconomyAPI extends PluginBase implements Listener {
/** @var UserProvider */
private $provider;

private $langList = [
"user-define" => "User Defined",
"ch" => "简体中文",
"cs" => "Čeština",
"en" => "English",
"fr" => "Français",
"id" => "Bahasa Indonesia",
"it" => "Italiano",
"ja" => "日本語",
"ko" => "한국어",
"nl" => "Nederlands",
"ru" => "Русский",
"zh" => "繁體中文",
];
const USER_DEFINED = 'user-define';

private $lang = [];

/**
Expand All @@ -147,6 +135,14 @@ public function getCommandMessage(string $command): array {
}
}

public function hasLanguage(string $lang): bool {
return isset($this->lang[$lang]);
}

public function getLanguages(): array {
return array_keys($this->lang);
}

/**
* @param string $key
* @param array $params
Expand Down Expand Up @@ -681,14 +677,6 @@ public function getSortByRange(Currency $currency, int $from, ?int $len = null):
return $holder->getProvider()->sortByRange($from, $len);
}

public function hasLanguage(string $lang): bool {
return isset($this->langList[$lang]);
}

public function getLanguages(): array {
return array_keys($this->langList);
}

public function getCurrencyConfig(Currency $currency): ?CurrencyConfig {
foreach($this->currencies as $config) {
if($config->getCurrency() === $currency) {
Expand Down Expand Up @@ -914,7 +902,7 @@ private function initializeLanguage() {
$this->lang[substr($filename, 5, -5)] = json_decode(file_get_contents($resource->getPathname()), true);
}
}
$this->lang["user-define"] = (new Config(
$this->lang[self::USER_DEFINED] = (new Config(
$this->getDataFolder() . "messages.yml", Config::YAML, $this->lang[self::FALLBACK_LANGUAGE]
))->getAll();
}
Expand Down

0 comments on commit b61fab9

Please sign in to comment.