Ejemplo n.º 1
0
 function runtest()
 {
     $test = new phplist_I18N();
     $test->language = 'nl';
     $dutch = file_get_contents(dirname(__FILE__) . '/../locale/nl/phplist.po');
     $lines = explode("\n", $dutch);
     $orig = $trans = '';
     $translations = array();
     foreach ($lines as $line) {
         if (preg_match('/^msgid "(.*)"$/', $line, $regs)) {
             $translations[$orig] = $trans;
             $orig = $regs[1];
             $trans = '';
         }
         if (preg_match('/^msgstr "(.*)"$/', $line, $regs)) {
             $trans .= $regs[1];
         }
     }
     $result = array('good' => 0, 'bad' => 0);
     foreach ($translations as $orig => $trans) {
         if (!empty($orig) && !empty($trans) && $orig != $trans) {
             if (strtolower($test->gettext($orig)) == strtolower($trans)) {
                 $result['good'] += 1;
                 //print "<h3>SUCCESS ON $orig</h3>";
                 //print "<p>$trans</p>";
                 //print '<p>'.$test->get($orig).'</p>';
             } else {
                 $result['bad'] += 1;
                 print "<h3>FAIL ON {$orig}</h3>";
                 print "<p>Should be <b>{$trans}</b></p>";
                 print '<p>Is currently <b>' . $test->gettext($orig) . '</b></p>';
             }
         }
     }
     var_dump($result);
 }
Ejemplo n.º 2
0
        } else {
            return $this->missingText($text);
        }
    }
}
function getTranslationUpdates()
{
    ## @@@TODO add some more error handling
    $LU = false;
    $lan_update = fetchUrl(TRANSLATIONS_XML);
    if (!empty($lan_update)) {
        $LU = @simplexml_load_string($lan_update);
    }
    return $LU;
}
$I18N = new phplist_I18N();
if (!empty($setlanguage)) {
    $I18N->resetCache();
}
/* add a shortcut that seems common in other apps 
 * function s($text)
 * @param $text string the text to find
 * @params 2-n variable - parameters to pass on to the sprintf of the text
 * @return translated text with parameters filled in
 * 
 * 
 * eg s("This is a %s with a %d and a %0.2f","text",6,1.98765);
 * 
 * will look for the translation of the string and substitute the parameters
 *  
 **/