diff --git a/composer.json b/composer.json index 2d58409..340d947 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nabeghe/light-localization", "description": "A light weight, key-value & path-based PHP localization library that translations are loaded up when needed.", "type": "library", - "version": "1.0.1", + "version": "1.0.2", "homepage": "https://github.com/nabeghe/light-localization", "license": "MIT", "autoload": { diff --git a/src/Localizer.php b/src/Localizer.php index e40cebe..cd63667 100644 --- a/src/Localizer.php +++ b/src/Localizer.php @@ -40,7 +40,54 @@ class Localizer protected array $translators = []; /** - * Retrieves the lost of loaded translators. + * Retrieves the root path. + */ + public function getPath(): string + { + return $this->path; + } + + /** + * Retrieves the current language code. + */ + public function getCode(): string + { + return $this->code; + } + + /** + * Changes the localization code. + * @param string $code New code. + * @param bool $refresh Optional. After changing the code, should it reload the loaded translators or remove all of them from the loaded state? Default false. + */ + public function setCode(string $code, bool $refresh = false): void + { + $this->code = $code; + if ($refresh) { + $this->refresh(); + } else { + $this->translators = []; + } + } + + /** + * An alias for the {@see setcode} + */ + public function recode(string $code, bool $refresh = false): void + { + $this->setCode($code, $refresh); + } + + /** + * Retrieves the default translation. + */ + public function getDefaultTranslation() + { + return $this->defaultTranslation; + } + + /** + * Retrieves the list of loaded translators. * @return array */ public function getTranslators(): array @@ -137,21 +184,6 @@ public function unload(string $translator = self::DEFAULT_TRANSLATOR): bool return false; } - /** - * Changes the localization code. - * @param string $code New code. - * @param bool $refresh Optional. After changing the code, should it reload the loaded translators or remove all of them from the loaded state? Default false. - */ - public function recode(string $code, bool $refresh = false): void - { - $this->code = $code; - if ($refresh) { - $this->refresh(); - } else { - $this->translators = []; - } - } - /** * Checks whether a key exists in a translator or not. * @param string $key