function do_merge($locale, $fuzzy) { global $dyn_locales_dir; if (chdir("{$dyn_locales_dir}/{$locale}/LC_MESSAGES/") == FALSE) { die("Unable to change to messages directory."); } // Try to back up the existing translation assert(file_exists("messages.po")); $save = "messages_" . strftime("%Y%m%d%H%M%S", filemtime("messages.po")) . ".po"; if (!@copy("messages.po", $save)) { echo "<p>" . _("Could not save a copy of the previous file.") . " " . _("File was not updated.") . "</p>"; return; } $po_filename = "{$dyn_locales_dir}/{$locale}/LC_MESSAGES/messages.po"; $pot_filename = "{$dyn_locales_dir}/messages.pot"; $po_file = new POFile($po_filename); try { $po_file->merge_from_template($pot_filename, $fuzzy == 'on'); echo "<p>" . _("File successfully updated. You may now download it.") . "</p>"; } catch (Exception $exception) { echo "<p>" . _("<code>msgmerge</code> reports the following errors:") . "</p>\n"; echo "<pre>"; foreach (explode("\n", $exception->getMessage()) as $v) { echo html_safe($v) . "\n"; } echo "</pre><br>"; return; } }