Minor improvements

This commit is contained in:
Wruczek 2020-10-08 06:29:13 +02:00
parent b736b13286
commit 753c6c7688
4 changed files with 8 additions and 15 deletions

View File

@ -93,7 +93,7 @@ class Auth {
try {
$client = TeamSpeakUtils::i()->getTSNodeServer()->clientGetByDbid($cldbid);
$code = (string) Utils::getSecureRandomInt(100000, 999999);
$msg = LanguageUtils::tl("LOGIN_CONFIRMATION_CODE", $code);
$msg = __get("LOGIN_CONFIRMATION_CODE", $code);
if ($poke) {
$client->poke(mb_substr($msg, 0, 100)); // Max 100 characters for pokes

View File

@ -19,17 +19,6 @@ class LanguageUtils {
private $cache;
private $languages;
/**
* Short function for translate
* @param string $identifier
* @param array|string $args
* @return string
* @throws \Exception
*/
public static function tl(string $identifier, $args = []): string {
return self::i()->translate($identifier, $args);
}
private function __construct() {
$this->cache = new PhpFileCache(__CACHE_DIR, "translations");

View File

@ -76,10 +76,14 @@ if(!isset($_SESSION["userlanguageid"])) {
try {
return LanguageUtils::i()->translate($identifier, $args);
} catch (\Exception $e) {
if ($nullOnError) {
return null;
} else {
return "(unknown translation for " . Utils::escape($identifier) . ")";
}
}
}
}
// Set timezone
date_default_timezone_set(Config::get("timezone"));

View File

@ -191,8 +191,8 @@ $navActiveIndex = isset($navActiveIndex) ? (int) $navActiveIndex : 0;
<!-- Moment.js 2.22.2 -->
{$tplutils::includeScript("{cdnjs}/moment.js/2.24.0/moment.min.js", "sha256-4iQZ6BVL4qNKlQ27TExEhBN1HFPvAvAMbFavKKosSWQ=")}
{var momentjslang = Wruczek\TSWebsite\Utils\Language\LanguageUtils::tl("MOMENTJS_LANG")}
{if $momentjslang !== "en-us"}
{var momentjslang = __get("MOMENTJS_LANG", [], true)}
{if $momentjslang !== null && $momentjslang !== "en-us"}
{$tplutils::includeScript("{cdnjs}/moment.js/2.24.0/locale/$momentjslang.js")}
<script>
moment.locale({$momentjslang} || navigator.languages || navigator.language)