Created
February 6, 2009 10:37
-
-
Save hugowetterberg/59325 to your computer and use it in GitHub Desktop.
Patch that allows decoupling of default and fallback language and uses the path prefix of the default language (if set)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a272fe19a5135b0256bb5af3210d89067fcfa257 Mon Sep 17 00:00:00 2001 | |
From: Hugo Wetterberg <[email protected]> | |
Date: Fri, 6 Feb 2009 11:09:02 +0100 | |
Subject: [PATCH] HACKED CORE! | |
It's now possible to set a default fallback language that's different from the default language. | |
--- | |
includes/language.inc | 19 ++++++++++++++----- | |
1 files changed, 14 insertions(+), 5 deletions(-) | |
diff --git a/includes/language.inc b/includes/language.inc | |
index 77ecb22..9227201 100644 | |
--- a/includes/language.inc | |
+++ b/includes/language.inc | |
@@ -46,7 +46,20 @@ function language_initialize() { | |
} | |
} | |
if ($mode == LANGUAGE_NEGOTIATION_PATH_DEFAULT) { | |
- // If we did not found the language by prefix, choose the default. | |
+ // If we did not found the language by prefix, choose the fallback language. | |
+ $default = language_default(); | |
+ $fallback_lang = variable_get('language_fallback', $default->language); | |
+ | |
+ if (isset($languages[$fallback_lang])) { | |
+ $fallback = $languages[$fallback_lang]; | |
+ | |
+ if ($fallback && $fallback->prefix) { | |
+ global $base_url; | |
+ header('Location: ' . $base_url . '/' . trim($fallback->prefix . '/' . $_GET['q'], '/')); | |
+ die; | |
+ } | |
+ } | |
+ | |
return language_default(); | |
} | |
break; | |
@@ -128,10 +141,6 @@ function language_url_rewrite(&$path, &$options) { | |
break; | |
case LANGUAGE_NEGOTIATION_PATH_DEFAULT: | |
- $default = language_default(); | |
- if ($options['language']->language == $default->language) { | |
- break; | |
- } | |
// Intentionally no break here. | |
case LANGUAGE_NEGOTIATION_PATH: | |
-- | |
1.6.1+GitX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment