コード例 #1
0
    die;
}
$source_folder = $argv[1];
$lang = $argv[2];
$output_folder = $argv[3];
$translation_xml_file = $argv[4];
if (!is_dir($source_folder)) {
    echo 'Error: source folder ' . $source_folder . ' does not exist' . PHP_EOL;
    die;
}
if (!in_array($lang, $accepted_languages)) {
    echo 'Error: language ' . $lang . ' not supported' . PHP_EOL;
    die;
}
template_set_errors_visible();
template_set_warnings_visible();
echo 'Translation of *all* templates in ' . $source_folder . ' will now start.' . PHP_EOL;
echo 'Output language: ' . $lang . PHP_EOL . PHP_EOL;
$files = template_list_files($source_folder);
//
// Parsing each template file
//
foreach ($files as $file) {
    //echo 'Translating ' . $file . '...' . PHP_EOL;
    template_parse($file, $lang, $output_folder, $translation_xml_file);
    //echo 'Translation complete' . PHP_EOL . PHP_EOL;
}
if (template_last_error() != '' || template_last_warning() != '') {
    echo PHP_EOL;
}
echo 'Translation finished, you can find your files in \'' . $output_folder . '/' . $lang . '\'' . PHP_EOL;
コード例 #2
0
ファイル: lib_template.php プロジェクト: jingyexu/ezcast
/**
 * Returns the *message* given as a parameter, in the language given as another parameter
 * @param type $id
 * @param type $lang 
 */
function template_get_message($id, $lang)
{
    global $dictionnary_xml;
    if ($dictionnary_xml == null) {
        template_last_error("Please load dictionnary before anything else");
        return false;
    }
    //fetch the element matching given id and language in xml stucture via xpath
    $res = $dictionnary_xml->xpath("/data/messages/message[@id='{$id}' and @lang='{$lang}']");
    if (!$res) {
        template_last_warning('Message ' . $id . ' not found for lang ' . $lang);
        return '';
    }
    $res = $res[0];
    return (string) $res;
}