mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
commit
e674383d2a
1 changed files with 23 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* Wifi Hotspot app for YunoHost
|
/* Wifi Hotspot app for YunoHost
|
||||||
|
@ -18,6 +19,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Limonade configuration
|
// Limonade configuration
|
||||||
function configure() {
|
function configure() {
|
||||||
option('env', ENV_PRODUCTION);
|
option('env', ENV_PRODUCTION);
|
||||||
|
@ -39,6 +42,10 @@ function T_($string) {
|
||||||
|
|
||||||
// Before routing
|
// Before routing
|
||||||
function before($route) {
|
function before($route) {
|
||||||
|
$lang_mapping = array(
|
||||||
|
'fr' => 'fr_FR'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * Locale
|
* * Locale
|
||||||
* */
|
* */
|
||||||
|
@ -46,19 +53,26 @@ function before($route) {
|
||||||
$locale = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
$locale = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
$_SESSION['locale'] = strtolower(substr(chop($locale[0]),0,2));
|
$_SESSION['locale'] = strtolower(substr(chop($locale[0]),0,2));
|
||||||
}
|
}
|
||||||
|
$lang = $_SESSION['locale'];
|
||||||
|
// Convert simple language code into full language code
|
||||||
|
if (array_key_exists($lang, $lang_mapping)) {
|
||||||
|
$lang = $lang_mapping[$lang];
|
||||||
|
}
|
||||||
|
$lang = $lang.'.utf8';
|
||||||
$textdomain="localization";
|
$textdomain="localization";
|
||||||
putenv('LANGUAGE='.$_SESSION['locale']);
|
|
||||||
putenv('LANG='.$_SESSION['locale']);
|
putenv('LANGUAGE='.$lang);
|
||||||
putenv('LC_ALL='.$_SESSION['locale']);
|
putenv('LANG='.$lang);
|
||||||
putenv('LC_MESSAGES='.$_SESSION['locale']);
|
putenv('LC_ALL='.$lang);
|
||||||
setlocale(LC_ALL,$_SESSION['locale']);
|
putenv('LC_MESSAGES='.$lang);
|
||||||
setlocale(LC_CTYPE,$_SESSION['locale']);
|
setlocale(LC_ALL,$lang);
|
||||||
$locales_dir = dirname(__FILE__).'/../i18n';
|
setlocale(LC_CTYPE,$lang);
|
||||||
|
$locales_dir = dirname(__FILE__).'/i18n';
|
||||||
bindtextdomain($textdomain,$locales_dir);
|
bindtextdomain($textdomain,$locales_dir);
|
||||||
bind_textdomain_codeset($textdomain, 'UTF-8');
|
bind_textdomain_codeset($textdomain, 'UTF-8');
|
||||||
textdomain($textdomain);
|
textdomain($textdomain);
|
||||||
// Set the $locale variable in template
|
// Set the $locale variable in template
|
||||||
set('locale', $_SESSION['locale']);
|
set('locale', $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After routing
|
// After routing
|
||||||
|
|
Loading…
Add table
Reference in a new issue