<?php
/*
* Jirafeau, your web file repository
- * Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
+ * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
+ * Copyright (C) 2015 Jerome Jutteau <jerome@jutteau.fr>
+ * Copyright (C) 2024 Jirafeau project <https://gitlab.com/jirafeau> (see AUTHORS.md)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
return "FIX ME";
}
-function t_visitor_langs() {
+function t_visitor_langs()
+{
$visitor_langs = t_parse_accept_language();
array_push($visitor_langs, "en");
return $visitor_langs;
}
-function t_parse_accept_language() {
+function t_parse_accept_language()
+{
if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
return [];
}
return $langs;
}
-function t_in($string_id, $lang) {
+function t_in($string_id, $lang)
+{
$trans = t_get_json($lang);
if ($trans === false) {
return false;
return $trans[$string_id];
}
-function t_get_raw_json($lang) {
+function t_get_raw_json($lang)
+{
$filename = str_replace("-", "_", $lang);
- if (preg_match('/[^A-Za-z_\w]/', $input)) {
+ if (preg_match('/[^A-Za-z_\w]/', $filename)) {
return false;
}
$p = JIRAFEAU_ROOT . "lib/locales/$filename.json";
return $json;
}
-function t_get_json($lang) {
+function t_get_json($lang)
+{
$raw_j = t_get_raw_json($lang);
$array = json_decode($raw_j, true);
if ($array === null) {
return $array;
}
-function json_lang_generator($lang) {
+function json_lang_generator($lang)
+{
$r = false;
if ($lang === null) {
$lang_config = $GLOBALS['cfg']['lang'];
if ($lang_config != "auto") {
$r = t_get_raw_json($lang_config);
} else {
- foreach(t_visitor_langs() as $lang) {
+ foreach (t_visitor_langs() as $lang) {
$r = t_get_raw_json($lang);
if (!($r === false)) {
break;