Exemple #1
0
 public function execute()
 {
     require_once $GLOBALS['rootpath'] . "okapi/locale/locales.php";
     $required = Locales::get_required_locales();
     $installed = Locales::get_installed_locales();
     $missing = array();
     foreach ($required as $locale) {
         if (!in_array($locale, $installed)) {
             $missing[] = $locale;
         }
     }
     if (count($missing) == 0) {
         return;
     }
     # okay!
     ob_start();
     print "Hi!\n\n";
     print "Your system is missing some locales required by OKAPI for proper\n";
     print "internationalization support. OKAPI comes with support for different\n";
     print "languages. This number (hopefully) will be growing.\n\n";
     print "Please take a moment to install the following missing locales:\n\n";
     $prefixes = array();
     foreach ($missing as $locale) {
         print " - " . $locale . "\n";
         $prefixes[substr($locale, 0, 2)] = true;
     }
     $prefixes = array_keys($prefixes);
     print "\n";
     if (count($missing) == 1 && $missing[0] == 'POSIX') {
         # I don't remember how to install POSIX, probably everyone has it anyway.
     } else {
         print "On Debian, try the following:\n\n";
         foreach ($prefixes as $lang) {
             if ($lang != 'PO') {
                 # Two first letters cut from POSIX.
                 print "sudo apt-get install language-pack-" . $lang . "-base\n";
             }
         }
         print "sudo service apache2 restart\n";
         print "\n";
     }
     print "Thanks!\n\n";
     print "-- \n";
     print "OKAPI Team";
     Okapi::mail_admins("Additional setup needed: Missing locales.", ob_get_clean());
 }
Exemple #2
0
 /**
  * Bind "okapi_messages" with our local i18n database. Set proper locale
  * based on the language codes passed and return the locale code.
  * $langprefs is a list of language codes in order of preference.
  *
  * Please note, that OKAPI consumers may ask OKAPI to return contents
  * in a specified language. (For example, consumers from Germany may ask
  * Polish OKAPI server to return GPX file in German.) If you insist on using
  * your own translation tables, you should still fallback to the default
  * OKAPI translations table in case of other languages!
  */
 public static function default_gettext_init($langprefs)
 {
     require_once $GLOBALS['rootpath'] . "okapi/locale/locales.php";
     $locale = Locales::get_best_locale($langprefs);
     putenv("LC_ALL={$locale}");
     setlocale(LC_ALL, $locale);
     setlocale(LC_NUMERIC, "POSIX");
     # We don't want *this one* to get out of control.
     bindtextdomain("okapi_messages", $GLOBALS['rootpath'] . 'okapi/locale');
     return $locale;
 }