diff options
author | Romain d'Alverny <rdalverny@gmail.com> | 2022-01-11 12:36:17 +0100 |
---|---|---|
committer | Romain d'Alverny <rdalverny@gmail.com> | 2022-01-11 12:36:17 +0100 |
commit | 138865bbde25bb6193930c98e30c33913d19e367 (patch) | |
tree | 626e8e26dd4f4776ce9f8cd743987f08377127ed /app/classes/Simplel10n.php | |
parent | 5f2b708377aec4bc5f1d731dfbb50557552d0482 (diff) | |
download | planet-138865bbde25bb6193930c98e30c33913d19e367.tar planet-138865bbde25bb6193930c98e30c33913d19e367.tar.gz planet-138865bbde25bb6193930c98e30c33913d19e367.tar.bz2 planet-138865bbde25bb6193930c98e30c33913d19e367.tar.xz planet-138865bbde25bb6193930c98e30c33913d19e367.zip |
Install code QA helpers, enforce PSR2
Installs phpcs, phpmd, parallel-lint, phpstan.
Diffstat (limited to 'app/classes/Simplel10n.php')
-rwxr-xr-x | app/classes/Simplel10n.php | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/app/classes/Simplel10n.php b/app/classes/Simplel10n.php index 79313b3..f84ef5c 100755 --- a/app/classes/Simplel10n.php +++ b/app/classes/Simplel10n.php @@ -1,24 +1,28 @@ <?php -class Simplel10n { +class Simplel10n +{ public $locale; public $l10nFolder; - public function __construct($locale='en') { + public function __construct($locale = 'en') + { $GLOBALS['locale'] = array(); $this->locale = $locale; $this->l10nFolder = __DIR__ . '/../l10n/'; $this->load($this->l10nFolder . $this->locale); } - public function setL1OnFolder($path) { + public function setL1OnFolder($path) + { $this->l10nFolder = $path; } - static function getString($str, $comment='') { - if(array_key_exists($str, $GLOBALS['locale'])) { + public static function getString($str, $comment = '') + { + if (array_key_exists($str, $GLOBALS['locale'])) { return trim(str_replace('{ok}', '', $GLOBALS['locale'][$str])); } else { return $str; @@ -29,23 +33,27 @@ class Simplel10n { * This is the same as getString except that we don't remove the {ok} string * This is needed only for the extraction script */ - static function extractString($str, $comment='') { - if(array_key_exists($str, $GLOBALS['locale'])) { + public static function extractString($str, $comment = '') + { + if (array_key_exists($str, $GLOBALS['locale'])) { return $GLOBALS['locale'][$str]; } else { return $str; } } - static function load($pathToFile) { + public static function load($pathToFile) + { - if (!file_exists($pathToFile . '.lang')) return false; + if (!file_exists($pathToFile . '.lang')) { + return false; + } $file = file($pathToFile . '.lang'); foreach ($file as $k => $v) { - if (substr($v,0,1) == ';' && !empty($file[$k+1])) { - $GLOBALS['locale'][trim(substr($v,1))] = trim($file[$k+1]); + if (substr($v, 0, 1) == ';' && !empty($file[$k+1])) { + $GLOBALS['locale'][trim(substr($v, 1))] = trim($file[$k+1]); } } } |