Browse Source

intl extension now suggested, not required: work in en_US when it is missing.

Frederic G. MARAND 12 years ago
parent
commit
e9751c101f
2 changed files with 27 additions and 23 deletions
  1. 24 22
      Memcache_UI/Core/Context.inc
  2. 3 1
      memcache_ui.php

+ 24 - 22
Memcache_UI/Core/Context.inc

@@ -213,30 +213,32 @@ namespace Memcache_UI\Core {
           '@intl' => 'intl',
         )), LOG_WARNING);
       }
+      else {
+        $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
 
-      $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
-      $this->setMessage(strtr('Requested locale: @locale', array('@locale' => $locale)), LOG_DEBUG);
-      if (!empty($locale)) {
-        $matches = array();
-        $count = preg_match('/^([a-z]{2}_[A-Z]{2})(\.(\w+))*/', $locale, $matches);
-        if ($count) {
-          $count = count($matches);
-        }
-        $locale = $count >= 2
-          ? $matches[1]
-          : 'en_US';
-        $codeset = $count >= 4
-          ? $matches[3]
-          : 'UTF8';
-        self::$locale = $locale . '.' . $codeset;
-        setlocale(LC_ALL, self::$locale);
+        $this->setMessage(strtr('Requested locale: @locale', array('@locale' => $locale)), LOG_DEBUG);
+        if (!empty($locale)) {
+          $matches = array();
+          $count = preg_match('/^([a-z]{2}_[A-Z]{2})(\.(\w+))*/', $locale, $matches);
+          if ($count) {
+            $count = count($matches);
+          }
+          $locale = $count >= 2
+            ? $matches[1]
+            : 'en_US';
+          $codeset = $count >= 4
+            ? $matches[3]
+            : 'UTF8';
+          self::$locale = $locale . '.' . $codeset;
+          setlocale(LC_ALL, self::$locale);
 
-        $domain = 'messages';
-        $translation_path = 'locale';
-        bindtextdomain($domain, $translation_path);
-        textdomain($domain);
-        bind_textdomain_codeset($domain, 'UTF8');
-        $this->setMessage(self::t('Locale: @locale', array('@locale' => self::$locale)), LOG_DEBUG);
+          $domain = 'messages';
+          $translation_path = 'locale';
+          bindtextdomain($domain, $translation_path);
+          textdomain($domain);
+          bind_textdomain_codeset($domain, 'UTF8');
+          $this->setMessage(self::t('Locale: @locale', array('@locale' => self::$locale)), LOG_DEBUG);
+        }
       }
     }
 

+ 3 - 1
memcache_ui.php

@@ -8,9 +8,11 @@
  *
  * Requirements:
  * - PHP >= 5.3
- * - intl extension
  *
  * Recommended:
+ * - intl extension
+ *   - on Ubuntu 11.04, this implies removing libidn, libsimplepie, and
+ *     dokuwiki, among others
  * - tidy extension
  */
 namespace Memcache_UI {