/**
  * Toma el valor para el idioma.
  * @param optional string $lang     The language abbriviation.
  *
  * @access public
  *
  */
 function setLang($lang = null)
 {
     include_once Util::base_Path('include/classes/nls.inc.php');
     //Debug::oneVar($lang, __FILE__, __LINE__);
     if (empty($lang) || !NLS::isValid($lang)) {
         if (Session::getValue('lang') != null) {
             $lang = Session::getValue('lang');
         } else {
             if (Session::getContextValue('gettext_lang') != null) {
                 $lang = Session::getContextValue('gettext_lang');
             } else {
                 $lang = 'es_ES';
             }
         }
     }
     Session::setValue('language', $lang);
     //Debug::oneVar($lang, __FILE__, __LINE__);
     /* First try language with the current charset. */
     $lang_charset = $lang . '.' . NLS::getCharset();
     if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
         /* Next try language with its default charset. */
         global $nls;
         $charset = !empty($nls['charsets'][$lang]) ? $nls['charsets'][$lang] : $nls['defaults']['charset'];
         $lang_charset = $lang . '.' . $charset;
         NLS::_cachedCharset(0, $charset);
         if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
             /* At last try language solely. */
             $lang_charset = $lang;
             setlocale(LC_ALL, $lang_charset);
         }
     }
     @putenv('LANG=' . $lang_charset);
     @putenv('LANGUAGE=' . $lang_charset);
 }
Beispiel #2
0
require_once HORDE_LIBS . 'Horde/CLI.php';
$c =& new Horde_CLI();
if (!$c->runningFromCLI()) {
    $c->fatal(_("This script must be run from the command line."));
}
$c->init();
require HORDE_BASE . '/config/nls.php';
require_once HORDE_LIBS . 'Horde/NLS.php';
if (!empty($language)) {
    $tmp = explode('.', $language);
    $language = $tmp[0];
    $language = NLS::_map(trim($language));
    if (!NLS::isValid($language)) {
        $language = NLS::_map(substr($language, 0, 2));
    }
    if (NLS::isValid($language)) {
        setlocale(LC_ALL, $language);
        bindtextdomain('horde', HORDE_BASE . '/locale');
        textdomain('horde');
        if (array_key_exists(1, $tmp) && function_exists('bind_textdomain_codeset')) {
            bind_textdomain_codeset('horde', $tmp[1]);
        }
    }
}
$c->writeln($c->bold(_("---------------------------")));
$c->writeln($c->bold(_("Horde translation generator")));
$c->writeln($c->bold(_("---------------------------")));
/* Sanity checks */
if (!extension_loaded('gettext')) {
    $c->writeln($c->red('Gettext extension not found!'));
    footer();