use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Text\Markdown;
+use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
function load_doc_file($s)
{
- global $lang;
- if (!isset($lang)) $lang = 'en';
+ $lang = Config::get('system', 'language');
$b = basename($s);
$d = dirname($s);
if (file_exists("$d/$lang/$b")) {
{
Nav::setSelected('help');
- global $lang;
-
$text = '';
if ($a->argc > 1) {
{
check_form_security_token_redirectOnErr('/register', 'register');
- global $lang;
-
$verified = 0;
$blocked = 1;
dbesc(DateTimeFormat::utcNow()),
intval($user['uid']),
dbesc($result['password']),
- dbesc($lang),
+ dbesc(Config::get('system', 'language')),
dbesc($_POST['permonlybox'])
);
* Provide Languange, Translation, and Localisation functions to the application
* Localisation can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
*/
-class L10n
+class L10n extends \Friendica\BaseObject
{
/**
* @brief get the prefered language from the HTTP_ACCEPT_LANGUAGE header
*/
public static function pushLang($language)
{
- global $lang, $a;
+ $a = self::getApp();
- $a->langsave = $lang;
+ $a->langsave = Config::get('system', 'language');
- if ($language === $lang) {
+ if ($language === $a->langsave) {
return;
}
}
$a->strings = [];
self::loadTranslationTable($language);
- $lang = $language;
+ Config::set('system', 'language', $language);
}
/**
*/
public static function popLang()
{
- global $lang, $a;
+ $a = self::getApp();
- if ($lang === $a->langsave) {
+ if (Config::get('system', 'language') === $a->langsave) {
return;
}
$a->strings = [];
}
- $lang = $a->langsave;
+ Config::set('system', 'language', $a->langsave);
}
/**
*/
public static function loadTranslationTable($lang)
{
- $a = get_app();
+ $a = self::getApp();
$a->strings = [];
// load enabled addons strings
*/
public static function t($s, ...$vars)
{
- $a = get_app();
+ $a = self::getApp();
if (empty($s)) {
return '';
* - L10n::tt('Like', 'Likes', $count)
* - L10n::tt("%s user deleted", "%s users deleted", count($users))
*
- * @global type $lang
* @param string $singular
* @param string $plural
* @param int $count
*/
public static function tt($singular, $plural, $count)
{
- global $lang;
- $a = get_app();
+ $lang = Config::get('system', 'language');
- if (x($a->strings, $singular)) {
+ if (!empty($a->strings[$singular])) {
$t = $a->strings[$singular];
if (is_array($t)) {
$plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);