]>
git.p6c8.net - jirafeau_mojo42.git/blob - lib/lang.php
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',
29 'ro' => 'Limba română',
36 $cfg = $GLOBALS['cfg'];
37 $languages_list = $GLOBALS['languages_list'];
39 /* Detect user's langage if we are in automatic mode. */
40 if (strcmp ($cfg['lang'], 'auto') == 0)
42 if (isset ($_SERVER['HTTP_ACCEPT_LANGUAGE']))
43 $l = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
50 /* Is the langage in the list ? */
52 foreach ($languages_list as $key => $v)
53 if (strcmp ($l, $key) == 0)
56 /* Don't translate english. */
57 if (!($found && strcmp ($l, "en")))
60 /* Open translation file. */
61 $trans_j = file_get_contents (JIRAFEAU_ROOT
. "lib/locales/$l.json");
62 if ($trans_j === FALSE)
66 $trans = json_decode ($trans_j, true);
70 /* Try to find translation. */
71 if (!array_key_exists ($text, $trans))
77 function json_lang_generator ()
79 $cfg = $GLOBALS['cfg'];
80 $languages_list = $GLOBALS['languages_list'];
82 /* Detect user's langage if we are in automatic mode. */
83 if (strcmp ($cfg['lang'], 'auto') == 0)
85 if (isset ($_SERVER['HTTP_ACCEPT_LANGUAGE']))
86 $l = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
93 /* Is the langage in the list ? */
95 foreach ($languages_list as $key => $v)
96 if (strcmp ($l, $key) == 0)
99 /* Don't translate english. */
100 if (!($found && strcmp ($l, "en")))
103 /* Open translation file. */
104 $trans_j = file_get_contents (JIRAFEAU_ROOT
. "lib/locales/$l.json");
patrick-canterino.de