aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2011-03-31 10:04:15 +0000
committerRomain d'Alverny <rda@mageia.org>2011-03-31 10:04:15 +0000
commit351ef244932aa1bb63b3092ef4c57f556956d7a4 (patch)
tree38f9a8785be7b7f6d846b783bbe1cc66396cdc7a
parent32c1555f69912b0572e0e1da0b3051475c3a25a3 (diff)
downloadwww-351ef244932aa1bb63b3092ef4c57f556956d7a4.tar
www-351ef244932aa1bb63b3092ef4c57f556956d7a4.tar.gz
www-351ef244932aa1bb63b3092ef4c57f556956d7a4.tar.bz2
www-351ef244932aa1bb63b3092ef4c57f556956d7a4.tar.xz
www-351ef244932aa1bb63b3092ef4c57f556956d7a4.zip
lang redirection changes
-rw-r--r--index.php10
-rw-r--r--langs.inc.php26
2 files changed, 27 insertions, 9 deletions
diff --git a/index.php b/index.php
index 28a39ede5..9dfedcb3e 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,6 @@
<?php
/**
+ *
*/
require_once 'langs.inc.php';
@@ -22,11 +23,4 @@ if (isset($_GET['flang']))
die;
}
-require_once 'localeDetection.class.php';
-
-$locale = new ChooseLocale(array_keys($langs));
-
-$locale->setDefaultLocale('en');
-
-header(sprintf('Location: /%s/', $locale->getCompatibleLocale()));
-die; \ No newline at end of file
+relocate($langs); \ No newline at end of file
diff --git a/langs.inc.php b/langs.inc.php
index b38c58ef2..29b66f070 100644
--- a/langs.inc.php
+++ b/langs.inc.php
@@ -21,4 +21,28 @@ $langs = array(
'sl' => 'Slovenščina',
'zh-cn' => '简体中文',
'zh-tw' => '正體中文'
-); \ No newline at end of file
+);
+
+/**
+ * Redirect to a localized path.
+ *
+ * @param array $langs list of languages
+ * @param string $page optional path to which we want to redirect
+ * @param string $default_locale
+ *
+ * @return void
+*/
+function relocate($langs, $page = '', $default_locale = 'en')
+{
+ require_once 'localeDetection.class.php';
+
+ $locale = new ChooseLocale(array_keys($langs));
+
+ $locale->setDefaultLocale($default_locale);
+
+ header(sprintf('Location: /%s/%s',
+ $locale->getCompatibleLocale(),
+ $page
+ ));
+ die;
+} \ No newline at end of file