X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FL10n.php;h=2c8a9eef9cd0ef4d14c5013509655ffbe20de8cd;hb=0a4119adaf6294bf43d135a0f435c1dd677c50e0;hp=1eae16bca868352abaeea26c8b76368c5af6ae32;hpb=0b97b32a591241bb693dd4cc3584f704bb14aa60;p=friendica.git diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 1eae16bca8..2c8a9eef9c 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -5,6 +5,7 @@ namespace Friendica\Core; use Friendica\Core\L10n\L10n as L10nClass; +use Friendica\DI; /** * Provide Language, Translation, and Localization functions to the application @@ -12,21 +13,6 @@ use Friendica\Core\L10n\L10n as L10nClass; */ class L10n { - /** - * @var L10nClass - */ - private static $l10n; - - /** - * Initializes the L10n static wrapper with the instance - * - * @param L10nClass $l10n The l10n class - */ - public static function init(L10nClass $l10n) - { - self::$l10n = $l10n; - } - /** * Returns the current language code * @@ -34,37 +20,23 @@ class L10n */ public static function getCurrentLang() { - return self::$l10n->getCurrentLang(); + return DI::l10n()->getCurrentLang(); } /** - * This function should be called before formatting messages in a specific target language - * different from the current user/system language. - * - * It saves the current translation strings in a separate variable and loads new translations strings. + * @param string $lang * - * If called repeatedly, it won't save the translation strings again, just load the new ones. + * @return L10nClass The new L10n class with the new language * - * @see popLang() - * @brief Stores the current language strings and load a different language. - * @param string $lang Language code - * @throws \Exception - */ - public static function pushLang($lang) - { - self::$l10n->pushLang($lang); - } - - /** - * Restores the original user/system language after having used pushLang() + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function popLang() + public static function withLang(string $lang) { - self::$l10n->popLang(); + return DI::l10n()->withLang($lang); } /** - * @brief Return the localized version of the provided string with optional string interpolation + * Return the localized version of the provided string with optional string interpolation * * This function takes a english string as parameter, and if a localized version * exists for the current language, substitutes it before performing an eventual @@ -77,15 +49,16 @@ class L10n * * @param string $s * @param array $vars Variables to interpolate in the translation string + * * @return string */ public static function t($s, ...$vars) { - return self::$l10n->t($s, $vars); + return DI::l10n()->t($s, ...$vars); } /** - * @brief Return the localized version of a singular/plural string with optional string interpolation + * Return the localized version of a singular/plural string with optional string interpolation * * This function takes two english strings as parameters, singular and plural, as * well as a count. If a localized version exists for the current language, they @@ -100,16 +73,17 @@ class L10n * @param string $singular * @param string $plural * @param int $count + * * @return string * @throws \Exception */ public static function tt(string $singular, string $plural, int $count) { - return self::$l10n->tt($singular, $plural, $count); + return DI::l10n()->tt($singular, $plural, $count); } /** - * @brief Return installed languages codes as associative array + * Return installed languages codes as associative array * * Scans the view/lang directory for the existence of "strings.php" files, and * returns an alphabetical list of their folder names (@-char language codes). @@ -121,28 +95,42 @@ class L10n */ public static function getAvailableLanguages() { - return self::$l10n::getAvailableLanguages(); + return L10nClass::getAvailableLanguages(); } /** - * @brief Translate days and months names. + * Translate days and months names. * * @param string $s String with day or month name. + * * @return string Translated string. */ public static function getDay($s) { - return self::$l10n->getDay($s); + return DI::l10n()->getDay($s); } /** - * @brief Translate short days and months names. + * Translate short days and months names. * * @param string $s String with short day or month name. + * * @return string Translated string. */ public static function getDayShort($s) { - return self::$l10n->getDayShort($s); + return DI::l10n()->getDayShort($s); + } + + /** + * Load poke verbs + * + * @return array index is present tense verb + * value is array containing past tense verb, translation of present, translation of past + * @hook poke_verbs pokes array + */ + public static function getPokeVerbs() + { + return DI::l10n()->getPokeVerbs(); } }