aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Lallement <dams@mageia.org>2011-02-15 17:59:55 +0000
committerDamien Lallement <dams@mageia.org>2011-02-15 17:59:55 +0000
commitc598c63d01083fcd1a6fdcbf624d7c059c8c0cb2 (patch)
treeb1a40b4f2efd780909634a0da966ad2eda7e9806
parenta283a87ff9c8ce205ad0d7ced2f5ca4b62885381 (diff)
downloadwww-c598c63d01083fcd1a6fdcbf624d7c059c8c0cb2.tar
www-c598c63d01083fcd1a6fdcbf624d7c059c8c0cb2.tar.gz
www-c598c63d01083fcd1a6fdcbf624d7c059c8c0cb2.tar.bz2
www-c598c63d01083fcd1a6fdcbf624d7c059c8c0cb2.tar.xz
www-c598c63d01083fcd1a6fdcbf624d7c059c8c0cb2.zip
new function to prevent 404 error with missing translations
-rw-r--r--langs.php15
-rw-r--r--lib/news.php2
2 files changed, 16 insertions, 1 deletions
diff --git a/langs.php b/langs.php
index c67331eaf..9638518e3 100644
--- a/langs.php
+++ b/langs.php
@@ -47,6 +47,21 @@ foreach ($langs as $k => $v)
$v);
}
+// prevent 404 error on /{$locale}/ with missing translation
+function locale_path($locale,$path)
+{
+ $filename = "/".$locale."/".$path."/";
+ if (file_exists($filename)
+ {
+ $url = $filename;
+ }
+ else
+ {
+ $url = "/en/".$path;
+ }
+ return $url;
+}
+
// global nav
$nav_list = array(
"/{$locale}/" => 'Mageia',
diff --git a/lib/news.php b/lib/news.php
index 0a7bcc3c5..f3160aee0 100644
--- a/lib/news.php
+++ b/lib/news.php
@@ -103,4 +103,4 @@ function get_news($locale = 'en', $count = 5, $cache_timeout = 5)
unset($feed);
return $items;
-} \ No newline at end of file
+}