]>
git.p6c8.net - jirafeau_project.git/blob - lib/lang.php
71bfbf08f05574ae5acbab705ab2e1f2d5b081ff
3 * Jirafeau, your web file repository
4 * Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 global $languages_list;
21 $languages_list = array('auto' => 'Automatic',
31 'pl' => 'Polszczyzna',
33 'pt_BR' => 'português (Brasil)',
34 'ro' => 'Limba română',
43 $cfg = $GLOBALS['cfg'];
44 $languages_list = $GLOBALS['languages_list'];
46 /* Detect user's langage if we are in automatic mode. */
47 if (strcmp($cfg['lang'], 'auto') == 0) {
48 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
49 $l = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
57 /* Is the langage in the list ? */
59 foreach ($languages_list as $key => $v) {
60 if (strcmp($l, $key) == 0) {
65 /* Don't translate english. */
66 if (!($found && strcmp($l, "en"))) {
70 /* Open translation file. */
71 $trans_j = file_get_contents(JIRAFEAU_ROOT
. "lib/locales/$l.json");
72 if ($trans_j === false) {
77 $trans = json_decode($trans_j, true);
78 if ($trans === null) {
82 /* Try to find translation. */
83 if (!array_key_exists($text, $trans)) {
90 function json_lang_generator()
92 $cfg = $GLOBALS['cfg'];
93 $languages_list = $GLOBALS['languages_list'];
95 /* Detect user's langage if we are in automatic mode. */
96 if (strcmp($cfg['lang'], 'auto') == 0) {
97 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
98 $l = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
106 /* Is the langage in the list ? */
108 foreach ($languages_list as $key => $v) {
109 if (strcmp($l, $key) == 0) {
114 /* Don't translate english. */
115 if (!($found && strcmp($l, "en"))) {
119 /* Open translation file. */
120 $trans_j = file_get_contents(JIRAFEAU_ROOT
. "lib/locales/$l.json");
patrick-canterino.de