コード例 #1
0
 $old_translations = loadPOT($pot_file);
 $sources = array_keys($old_translations);
 foreach ($sources as $i => $source) {
     if (strlen(trim($source)) == 0) {
         unset($sources[$i]);
         continue;
     }
 }
 $old_src = chooseMenuValue("Which string would you like to change?", $sources);
 do {
     $new_src = trim(ask("What is the new source?"));
 } while (!simple_prompt("Replace:\n\t{$old_src}\nto:\n\t{$new_src}"));
 if (simple_prompt("Would you like to preserve the existing translations in the .po files for the locales " . implode(",", array_keys($avail_locales)) . "?")) {
     foreach ($avail_locales as $avail_locale => $avail_locale_file) {
         I2CE::raiseError("Updateing {$lp_module}'s {$avail_locale}.po");
         $loc_translations = loadPot($avail_locale_file);
         $top_module = $found_modules[$module];
         $new_loc_translations = array();
         foreach ($loc_translations as $key => $vals) {
             if ($key == $old_src) {
                 $key = $new_src;
             }
             $new_loc_translations[$key] = $vals;
         }
         writeOutPOT($avail_locale_file, $top_module, $module, $module_vers, $new_loc_translations);
     }
 }
 $new_translations = array();
 foreach ($old_translations as $key => $vals) {
     if ($key == $old_src) {
         $new_translations[$key] = $new_src;
コード例 #2
0
$changed_pos = array();
foreach ($found_modules as $module => $top_module) {
    $launch_module = launchpad($module);
    $pot_dir = $templates_dir . DIRECTORY_SEPARATOR . $launch_module;
    if (!is_dir($pot_dir)) {
        if (!mkdir($pot_dir, 0775, true)) {
            usage("Could not make {$pot_dir}");
        }
    }
    $pot_file = $pot_dir . DIRECTORY_SEPARATOR . $launch_module . '.pot';
    if (!is_array($current_template = loadPOT($pot_file))) {
        continue;
    }
    $po_files = glob(dirname($pot_file) . DIRECTORY_SEPARATOR . "*.po");
    foreach ($po_files as $po_file) {
        if (!is_array($new_trans = loadPot($po_file))) {
            continue;
        }
        $old_content = array();
        exec("bzr cat -r " . $args['rev'] . " " . $po_file, $old_content);
        $old_content = $old_content;
        if (!is_array($old_trans = loadPotByContent($old_content))) {
            continue;
        }
        $changed = 0;
        foreach ($current_template as $english_source => $data) {
            if (!array_key_exists($english_source, $old_trans) || !is_array($old_trans[$english_source]) || !array_key_exists('msgstr', $old_trans[$english_source]) || !trim($old_trans[$english_source]['msgstr'])) {
                continue;
            }
            if (!array_key_exists($english_source, $new_trans) || !is_array($new_trans[$english_source]) || !array_key_exists('msgstr', $new_trans[$english_source]) || !trim($new_trans[$english_source]['msgstr'])) {
                echo "{$po_file}: " . $old_trans[$english_source]['msgstr'] . " missing ({$english_source})\n";