Esempio n. 1
0
 /**
  * Translate a string
  *
  * @param string $chaine The string to translate
  *
  * @return Translated string (if available) ; $chaine otherwise
  */
 function _T($chaine)
 {
     global $language, $disable_gettext, $installer;
     if ($disable_gettext === true && isset($GLOBALS['lang'])) {
         $trans = $chaine;
         if (isset($GLOBALS['lang'][$chaine]) && $GLOBALS['lang'][$chaine] != '') {
             $trans = $GLOBALS['lang'][$chaine];
         } else {
             $trans = false;
             if (!isset($installer) || $installer !== true) {
                 $trans = getDynamicTranslation($chaine, $language);
             }
             if ($trans) {
                 $GLOBALS['lang'][$chaine] = $trans;
             } else {
                 $trans = $chaine . ' (not translated)';
             }
         }
         return $trans;
     } else {
         return _($chaine);
     }
 }
Esempio n. 2
0
        $exists = true;
        if ($text_orig == '') {
            $text_orig = $orig[0];
        } else {
            if (!in_array($text_orig, $orig)) {
                $exists = false;
                $error_detected[] = str_replace('%s', $text_orig, _T("No translation for '%s'!<br/>Please fill and submit above form to create it."));
            }
        }
        $trans = array();
        /**
         * FIXME : it would be faster to get all translations at once
         * for a specific string
         */
        foreach ($i18n->getList() as $l) {
            $text_trans = getDynamicTranslation($text_orig, $l->getLongID());
            $lang_name = $l->getName();
            $trans[] = array('key' => $l->getLongID(), 'name' => ucwords($lang_name), 'text' => $text_trans);
        }
        $tpl->assign('exists', $exists);
        $tpl->assign('orig', $orig);
        $tpl->assign('trans', $trans);
    } catch (Exception $e) {
        Analog::log('An error occured retrieving l10n entries | ' . $e->getMessage(), Analog::WARNING);
    }
}
$tpl->assign('page_title', _T("Translate labels"));
$tpl->assign('text_orig', $text_orig);
$tpl->assign('error_detected', $error_detected);
$tpl->assign('success_detected', $success_detected);
$content = $tpl->fetch('traduire_libelles.tpl');