Skip to content

Commit

Permalink
Fix active language file value (NamelessMC#3004)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadhgboyle authored Aug 8, 2022
1 parent a73e4bc commit 8dba3c3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/classes/Core/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function __construct(string $module = 'core', string $active_language = n
$path = str_replace('/', DIRECTORY_SEPARATOR, $module) . DIRECTORY_SEPARATOR . '__lng__.json';
}

$this->_activeLanguageFile = $path;
$this->_activeLanguageFile = str_replace('__lng__', $this->_activeLanguage, $path);

// HTML language definition
if (!defined('HTML_LANG')) {
Expand All @@ -202,7 +202,7 @@ public function __construct(string $module = 'core', string $active_language = n

$this->_i18n = new i18next(
$this->_activeLanguage,
$this->_activeLanguageFile,
$path,
'en_UK'
);
}
Expand Down Expand Up @@ -254,13 +254,12 @@ public function getPluralForm(): ?Closure {
* @param string $value New value to set for term.
*/
public function set(string $section, string $term, string $value): void {
$editing_file = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'languages', $this->_activeLanguage . '.json']);
$json = json_decode(file_get_contents($editing_file), true);
$json = json_decode(file_get_contents($this->_activeLanguageFile), true);

$json[$section . '/' . $term] = $value;

ksort($json);
file_put_contents($editing_file, json_encode($json, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
file_put_contents($this->_activeLanguageFile, json_encode($json, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
}

/**
Expand Down

0 comments on commit 8dba3c3

Please sign in to comment.