*/
namespace Friendica\Core;
-use Friendica\BaseObject;
use Friendica\Core\L10n\L10n as L10nClass;
+use Friendica\DI;
/**
* Provide Language, Translation, and Localization functions to the application
* Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
*/
-class L10n extends BaseObject
+class L10n
{
/**
* Returns the current language code
*/
public static function getCurrentLang()
{
- return self::getClass(L10nClass::class)->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.
+ * @param string $lang
*
- * It saves the current translation strings in a separate variable and loads new translations strings.
+ * @return L10nClass The new L10n class with the new language
*
- * If called repeatedly, it won't save the translation strings again, just load the new ones.
- *
- * @param string $lang Language code
- *
- * @throws \Exception
- * @see popLang()
- * @brief Stores the current language strings and load a different language.
- */
- public static function pushLang($lang)
- {
- self::getClass(L10nClass::class)->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::getClass(L10nClass::class)->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
*/
public static function t($s, ...$vars)
{
- return self::getClass(L10nClass::class)->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
*/
public static function tt(string $singular, string $plural, int $count)
{
- return self::getClass(L10nClass::class)->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).
}
/**
- * @brief Translate days and months names.
+ * Translate days and months names.
*
* @param string $s String with day or month name.
*
*/
public static function getDay($s)
{
- return self::getClass(L10nClass::class)->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.
*
*/
public static function getDayShort($s)
{
- return self::getClass(L10nClass::class)->getDayShort($s);
+ return DI::l10n()->getDayShort($s);
}
/**
*/
public static function getPokeVerbs()
{
- return self::getClass(L10nClass::class)->getPokeVerbs();
+ return DI::l10n()->getPokeVerbs();
}
}