logo

blog

Unnamed repository; edit this file 'description' to name the repository.
commit 059e48a0b7977445283144f584f4faa4126f9929
parent 7ef634d5c43324deb68092c5a961c7a70b83a096
Author: lanodan <lanodan.delta@free.fr>
Date:   Fri, 28 Feb 2014 18:51:39 +0100

Lang system

Diffstat:
.index.php.swp | 0
.links.php.swp | 0
.navbar.php.swp | 0
index.php | 10++--------
lang/.en.php.swo | 0
lang/.en.php.swp | 0
lang/.fr.php.swo | 0
lang/.fr.php.swp | 0
lang/.index.php.swp | 0
lang/.lang.php.swp | 0
lang/en.php | 2+-
lang/index.php | 9+++++++++
lang/lang.php | 17++++++++---------
links.php | 4++--
navbar.php | 4++--
15 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/.index.php.swp b/.index.php.swp Binary files differ. diff --git a/.links.php.swp b/.links.php.swp Binary files differ. diff --git a/.navbar.php.swp b/.navbar.php.swp Binary files differ. diff --git a/index.php b/index.php @@ -1,17 +1,11 @@ <?php -require_once('lang/lang.php'); - -if (empty($p)) { - $page['title']=mainPage; -} - -$title=$page['title'].baseTitle; + include 'lang/lang.php'; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> - <title><?=$title?></title> + <title><?=mainPage.baseTitle?></title> <link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="stylesheet" type="text/css" href="css/navbar.css"> </head> diff --git a/lang/.en.php.swo b/lang/.en.php.swo Binary files differ. diff --git a/lang/.en.php.swp b/lang/.en.php.swp Binary files differ. diff --git a/lang/.fr.php.swo b/lang/.fr.php.swo Binary files differ. diff --git a/lang/.fr.php.swp b/lang/.fr.php.swp Binary files differ. diff --git a/lang/.index.php.swp b/lang/.index.php.swp Binary files differ. diff --git a/lang/.lang.php.swp b/lang/.lang.php.swp Binary files differ. diff --git a/lang/en.php b/lang/en.php @@ -2,7 +2,7 @@ /** * @file - * French language file. + * English language file. */ define('mainPage', 'Main Page'); diff --git a/lang/index.php b/lang/index.php @@ -0,0 +1,9 @@ +<?php + $known_languages = array('fr', 'en'); ## just add new language here when you need + $lang = 'fr'; //default language setting + $lang = $_COOKIE['lang']; + $lang = $_GET['lang'];//let user define his lang setting + + setcookie(lang, $lang); + header('Location: /') +?> diff --git a/lang/lang.php b/lang/lang.php @@ -1,13 +1,12 @@ <?php -$known_languages = array('fr', 'en'); ## just add new language here when you need -session_start(); + $known_languages = array('fr', 'en'); //just add new language here when you need + if (empty($_COOKIE['lang'])) { + setcookie(lang, 'fr'); + $lang = 'fr'; + } else { + $lang = $_COOKIE['lang']; + } -$lang = 'fr'; //default language setting -$lang = $_SESSION['lang']; -$lang = $_GET['lang'];//let user define his lang setting -if ($lang != $_SESSION['lang'] && in_array($lang, $known_languages)) { - $_SESSION['lang'] = $lang; -} -include($lang.'.php'); + include 'lang/'.$lang.'.php'; ?> diff --git a/links.php b/links.php @@ -1,11 +1,11 @@ <?php -require_once('lang/lang.php'); + include 'lang/lang.php'; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> - <title><?=$title?></title> + <title><?=links.baseTitle?></title> <link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="stylesheet" type="text/css" href="css/navbar.css"> </head> diff --git a/navbar.php b/navbar.php @@ -22,8 +22,8 @@ <ul class="right"> <li>lang <ul> - <li><a href="/lang/lang?lang=fr">Francais</a></li> - <li><a href="/lang/lang?lang=en">English</a></li> + <li><a href="/lang/?lang=fr">Francais</a></li> + <li><a href="/lang/?lang=en">English</a></li> </ul> </li> <li><a href="/rss">RSS</a></li>