aboutsummaryrefslogtreecommitdiffstats
path: root/localeDetection.class.php
diff options
context:
space:
mode:
authorMarek Laane <bald@smail.ee>2014-10-12 10:54:11 +0300
committerMarek Laane <bald@smail.ee>2014-10-12 10:54:11 +0300
commita0b2d09125d7911656fe4cb286f20643c4432281 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /localeDetection.class.php
parente32d8242187534c387106ff344201c42ff6afb44 (diff)
downloadwww-a0b2d09125d7911656fe4cb286f20643c4432281.tar
www-a0b2d09125d7911656fe4cb286f20643c4432281.tar.gz
www-a0b2d09125d7911656fe4cb286f20643c4432281.tar.bz2
www-a0b2d09125d7911656fe4cb286f20643c4432281.tar.xz
www-a0b2d09125d7911656fe4cb286f20643c4432281.zip
Updated Estonian translation
Diffstat (limited to 'localeDetection.class.php')
-rw-r--r--localeDetection.class.php119
1 files changed, 0 insertions, 119 deletions
diff --git a/localeDetection.class.php b/localeDetection.class.php
deleted file mode 100644
index d2a3a089d..000000000
--- a/localeDetection.class.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-
-/* ChooseLocale
- *
- * Licence: MPL 2/GPL 2.0/LGPL 2.1
- * Author: Pascal Chevrel, Mozilla
- * Date : 2010-07-17
- *
- * Description:
- * Class to choose the locale which locale we will show to the visitor
- * based on http acceptlang headers and our list of supported locales.
- *
- *
-*/
-
-
-
-
-class ChooseLocale
-{
- public $HTTPAcceptLang;
- public $supportedLocales;
- protected $detectedLocale;
- protected $defaultLocale;
- public $mapLonglocales;
-
-
- public function __construct($list=array('en-US'), $force_http_accept_language = null)
- {
- if (null !== $force_http_accept_language) {
- $this -> HTTPAcceptLang = $force_http_accept_language;
- } else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
- $this -> HTTPAcceptLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
- }
-
- $this -> supportedLocales = array_unique($list);
- $this -> setDefaultLocale('en-US');
- $this -> setCompatibleLocale();
- $this -> mapLonglocales = true;
-
- }
-
- public function getAcceptLangArray()
- {
- if (empty($this->HTTPAcceptLang)) return null;
-
- return explode(',', strtolower($this->HTTPAcceptLang));
- }
-
- public function getCompatibleLocale()
- {
- $l = $this -> defaultLocale;
- $acclang = $this -> getAcceptLangArray();
-
- if(!is_array($acclang)) {
- return $this -> defaultLocale;
- }
-
- foreach ($acclang as $var) {
- $locale = $this -> _cleanHTTPlocaleCode($var);
- $shortLocale = array_shift(explode('-', $locale));
-
- if (in_array($locale, $this -> supportedLocales)) {
- $l = $locale;
- break;
- }
-
- if (in_array($shortLocale, $this -> supportedLocales)) {
- $l = $shortLocale;
- break;
- }
-
- // check if we map visitors short locales to site long locales
- // like en -> en-GB
- if ($this -> mapLonglocales == true) {
- foreach ($this -> supportedLocales as $var) {
- $shortSupportedLocale = array_shift(explode('-', $var));
- if ($shortLocale == $shortSupportedLocale) {
- $l = $var;
- break;
- }
- }
- }
-
- }
-
- return $l;
- }
-
- public function getDefaultLocale() {
- return $this -> defaultLocale;
- }
-
- public function setCompatibleLocale() {
- $this -> detectedLocale = $this -> getCompatibleLocale();
- }
-
- public function setDefaultLocale($locale) {
-
- // the default locale should always be among the site locales
- // if not, the first locale in the supportedLocales array is default
- if (!in_array($locale, $this -> supportedLocales)) {
- $this -> defaultLocale = $this -> supportedLocales[0];
-
- } else {
- $this -> defaultLocale = $locale;
- }
- return;
- }
-
- private function _cleanHTTPlocaleCode($str)
- {
- $locale = explode(';', $str);
- $locale = trim($locale[0]);
-
- return $locale;
- }
-
-} \ No newline at end of file