Skip to content
Snippets Groups Projects
Commit 81194831 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Change in getLanguage, that allows to not fallback to default or http preferences

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1138 44740490-163a-0410-bde0-09ae8108e29a
parent ff826567
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,7 @@ class SimpleSAML_XHTML_Template { ...@@ -87,7 +87,7 @@ class SimpleSAML_XHTML_Template {
* then it tries to calculate the preferred language from HTTP headers. * then it tries to calculate the preferred language from HTTP headers.
* Last it returns the default language. * Last it returns the default language.
*/ */
public function getLanguage() { public function getLanguage($checkHTTP = TRUE, $defaultFallback = TRUE) {
// Language is set in object // Language is set in object
if (isset($this->language)) { if (isset($this->language)) {
...@@ -99,15 +99,20 @@ class SimpleSAML_XHTML_Template { ...@@ -99,15 +99,20 @@ class SimpleSAML_XHTML_Template {
$this->language = $_COOKIE['language']; $this->language = $_COOKIE['language'];
return $this->language; return $this->language;
} }
/* Check if we can find a good language from the Accept-Language http header. */ if ($checkHTTP) {
$httpLanguage = $this->getHTTPLanguage(); /* Check if we can find a good language from the Accept-Language http header. */
if ($httpLanguage !== NULL) { $httpLanguage = $this->getHTTPLanguage();
return $httpLanguage; if ($httpLanguage !== NULL) {
return $httpLanguage;
}
} }
// Language is not set, and we get the default language from the configuration. // Language is not set, and we get the default language from the configuration.
return $this->getDefaultLanguage(); if ($defaultFallback)
return $this->getDefaultLanguage();
return NULL;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment