global $curdir;
chdir($dir);
- $langs = get_po_files('po');
- $langs = array_map(create_function('$lang', 'return str_replace("po" . DS, "", str_replace(".po", "", $lang));'), $langs);
+ $langs = get_po_files('locale');
+ $langs = array_map('basename', array_map('dirname', array_map('dirname', $langs)));
chdir($curdir);
return $langs;
}
function search_applications()
{
$dirs = array();
- if (is_dir(HORDE_BASE . DS . 'po')) {
+ if (is_dir(HORDE_BASE . DS . 'locale')) {
$dirs[] = HORDE_BASE;
}
$dh = opendir(BASE);
$sub = opendir($dir);
if ($sub) {
while ($subentry = readdir($sub)) {
- if ($subentry == 'po' && is_dir($dir . DS . $subentry)) {
+ if ($subentry == 'locale' && is_dir($dir . DS . $subentry)) {
$dirs[] = $dir;
break;
}
}
printf('Extracting from %s... ', $apps[$i]);
chdir($dirs[$i]);
+ $files = array();
if ($apps[$i] == 'horde') {
- $files = search_ext('php', '.', true);
- foreach (array('admin', '../framework', 'lib', 'services', 'templates', 'util', 'themes') as $search_dir) {
- $files = array_merge($files, search_ext('(php|inc|js)', $search_dir));
- }
- $files = array_merge($files, search_ext('dist', 'config'));
+ $files = search_ext('(php|inc)', '../framework');
$files[] = 'config/nls.php';
- $sh = $GLOBALS['xgettext'] . ' --language=' . $language .
- ' --from-code=iso-8859-1 --keyword=_ --sort-output --copyright-holder="Horde Project"';
- if ($gettext_version[0] > 0 || $gettext_version[1] > 11) {
- $sh .= ' --msgid-bugs-address="dev@lists.horde.org"';
- }
- $file = $dirs[$i] . DS . 'po' . DS . $apps[$i] . '.pot';
- if (file_exists($file) && !is_writable($file)) {
- $c->message(sprintf('%s is not writable.', $file), 'cli.error');
- footer();
- }
- $tmp_file = $file . '.tmp.pot';
- $sh .= ' -o ' . $tmp_file . ' ' . implode(' ', $files);
- if (file_exists($dirs[$i] . '/po/translation.php')) {
- $sh .= ' po/translation.php';
- }
- if (!$debug) {
- $sh .= $silence;
- }
- if ($debug || $test) {
- $c->writeln('Executing:');
- $c->writeln($sh);
- }
- if (!$test) {
- exec($sh);
- }
- } else {
- $files = search_ext('(php|inc|js)');
- $files = array_filter($files, create_function('$file', 'return substr($file, 0, 9) != "." . DS . "config" . DS;'));
- $files = array_merge($files, search_ext('dist', 'config'));
- $sh = $GLOBALS['xgettext'] . ' --language=' . $language .
- ' --keyword=_ --sort-output --force-po --copyright-holder="Horde Project"';
- if ($gettext_version[0] > 0 || $gettext_version[1] > 11) {
- $sh .= ' --msgid-bugs-address="dev@lists.horde.org"';
- }
- $file = 'po' . DS . $apps[$i] . '.pot';
- if (file_exists($file) && !is_writable($file)) {
- $c->message(sprintf('%s is not writable.', $file), 'cli.error');
- footer();
- }
- $tmp_file = $file . '.tmp.pot';
- $sh .= ' -o ' . $tmp_file . ' ' . implode(' ', $files) . ($debug ? '' : $silence);
- if ($debug || $test) {
- $c->writeln('Executing:');
- $c->writeln($sh);
- }
- if (!$test) {
- exec($sh);
- }
}
+ $files = array_merge($files, search_ext('(php|inc)'));
+ $files = array_filter($files, create_function('$file', 'return substr($file, 0, 9) != "." . DS . "config" . DS;'));
+ $files = array_merge($files, search_ext('dist', 'config'));
+ $file = 'locale' . DS . $apps[$i] . '.pot';
+ file_put_contents($file . '.list', implode("\n", $files));
+ if (file_exists($file) && !is_writable($file)) {
+ $c->message(sprintf('%s is not writable.', $file), 'cli.error');
+ footer();
+ }
+ $tmp_file = $file . '.tmp.pot';
+ $sh = $GLOBALS['xgettext'] . ' --language=' . $language .
+ ' --from-code=iso-8859-1 --keyword=_ --sort-output --copyright-holder="Horde Project" --msgid-bugs-address="dev@lists.horde.org" --files-from=' . $file . '.list --output=' . $tmp_file;
+ if ($debug) {
+ $sh .= $silence;
+ }
+ if ($debug || $test) {
+ $c->writeln('Executing:');
+ $c->writeln($sh);
+ $c->writeln('In: ' . getcwd());
+ }
+ if (!$test) {
+ exec($sh);
+ }
+ unlink($file . '.list');
$diff = array();
if (file_exists($tmp_file)) {
$files = search_ext('html', 'templates');
{
global $cmd_options, $apps, $dirs, $debug, $test, $c;
- $compendium = ' --compendium="' . HORDE_BASE . DS . 'po' . DS . 'compendium.po"';
+ $compendium = ' --compendium="' . HORDE_BASE . DS . 'locale' . DS . 'compendium.po"';
foreach ($cmd_options[0] as $option) {
switch ($option[0]) {
case 'h':
break;
}
}
- if (!isset($lang) && !empty($compendium)) {
- $c->message('No locale specified.', 'cli.error');
- $c->writeln();
- usage();
- footer();
- }
cleanup();
continue;
}
$c->writeln(sprintf('Merging translation for module %s...', $c->bold($apps[$i])));
- $dir = $dirs[$i] . DS . 'po' . DS;
+ $dir = $dirs[$i] . DS . 'locale' . DS;
+ $po = $dir . '%s' . DS . 'LC_MESSAGES' . DS . $apps[$i] . '.po';
if (empty($lang)) {
$langs = get_languages($dirs[$i]);
} else {
- if (!file_exists($dir . $lang . '.po')) {
+ if (!file_exists(sprintf($po, $lang))) {
$c->writeln('Skipped...');
$c->writeln();
continue;
}
foreach ($langs as $locale) {
$c->writeln(sprintf('Merging locale %s... ', $c->bold($locale)));
- $sh = $GLOBALS['msgmerge'] . ' --update -v' . $compendium . ' "' . $dir . $locale . '.po" "' . $dir . $apps[$i] . '.pot"';
+ $sh = $GLOBALS['msgmerge']
+ . sprintf(' --update -v%s "%s" "%s.pot"',
+ $compendium, sprintf($po, $locale), $dir . $apps[$i]);
if ($debug || $test) {
$c->writeln('Executing:');
$c->writeln($sh);
if (empty($lang)) {
$langs = get_languages($dirs[$i]);
} else {
- if (!file_exists($dirs[$i] . DS . 'po' . DS . $lang . '.po')) {
+ if (!file_exists($dirs[$i] . '/locale/' . $lang . '/LC_MESSAGES/' . $apps[$i] . '.po')) {
$c->writeln('Skipped...');
$c->writeln();
continue;
{
global $cmd_options, $dirs, $debug, $test, $c, $silence;
- $dir = HORDE_BASE . DS . 'po' . DS;
+ $dir = HORDE_BASE . DS . 'locale' . DS;
$add = '';
foreach ($cmd_options[0] as $option) {
switch ($option[0]) {
printf('Merging all %s.po files to the compendium... ', $lang);
$pofiles = array();
for ($i = 0; $i < count($dirs); $i++) {
- $pofile = $dirs[$i] . DS . 'po' . DS . $lang . '.po';
+ $pofile = $dirs[$i] . DS . 'locale' . DS . $lang . DS . 'LC_MESSAGES' . DS . $apps[$i] . '.po';
if (file_exists($pofile)) {
$pofiles[] = $pofile;
}
$package = ucfirst($apps[$i]);
$version = $registry->getVersion($apps[$i]);
printf('Initializing module %s... ', $apps[$i]);
- if (!file_exists($dirs[$i] . '/po/' . $apps[$i] . '.pot')) {
+ $dir = $dirs[$i] . DS . 'locale' . DS;
+ $pot = $dir . $apps[$i] . '.pot';
+ if (!file_exists($pot)) {
$c->writeln();
- $c->message(sprintf('%s not found. Run \'translation extract\' first.', $dirs[$i] . DS . 'po' . DS . $apps[$i] . '.pot'), 'cli.warning');
+ $c->message(sprintf('%s not found. Run \'translation extract\' first.', $pot), 'cli.warning');
continue;
}
- $dir = $dirs[$i] . DS . 'po' . DS;
- $sh = $GLOBALS['msginit'] . ' --no-translator -i ' . $dir . $apps[$i] . '.pot ' .
- (!empty($lang) ? ' -o ' . $dir . $lang . '.po --locale=' . $lang : '') .
- ($debug ? '' : $silence);
+ $sh = $GLOBALS['msginit'] . ' --no-translator -i ' . $pot;
+ if (!empty($lang)) {
+ $sh .= ' -o ' . $dir . $lang . '.po --locale=' . $lang;
+ }
+ if (!$debug) {
+ $sh .= $silence;
+ }
if (!empty($lang) && !OS_WINDOWS) {
$pofile = $dirs[$i] . '/po/' . $lang . '.po';
$sh .= "; sed 's/PACKAGE package/$package package/' $pofile " .
{
global $cmd_options, $apps, $dirs, $debug, $test, $c, $silence, $redir_err;
- $compendium = HORDE_BASE . DS . 'po' . DS . 'compendium.po';
+ $compendium = HORDE_BASE . DS . 'locale' . DS . 'compendium.po';
$save_stats = false;
foreach ($cmd_options[0] as $option) {
switch ($option[0]) {
continue;
}
$c->writeln(sprintf('Building MO files for module %s...', $c->bold($apps[$i])));
+ $dir = $dirs[$i] . DS . 'locale' . DS . '%s' . DS . 'LC_MESSAGES' . DS;
if (empty($lang)) {
$langs = get_languages($dirs[$i]);
} else {
- if (!file_exists($dirs[$i] . DS . 'po' . DS . $lang . '.po')) {
+ if (!file_exists(sprintf($dir, $lang) . $apps[$i] . '.po')) {
$c->writeln('Skipped...');
$c->writeln();
continue;
}
foreach ($langs as $locale) {
$c->writeln(sprintf('Building locale %s...', $c->bold($locale)));
- $dir = $dirs[$i] . DS . 'locale' . DS . $locale . DS . 'LC_MESSAGES';
- if (!is_dir($dir)) {
+ $targetdir = sprintf($dir, $locale);
+ $pofile = $targetdir . $apps[$i] . '.po';
+ if (!is_dir($targetdir)) {
if ($debug) {
- $c->writeln(sprintf('Making directory %s', $dir));
+ $c->writeln(sprintf('Making directory %s', $targetdir));
}
- if (!$test && !System::mkdir("-p $dir")) {
+ if (!$test && !System::mkdir("-p $targetdir")) {
$c->message(sprintf('Could not create locale directory for locale %s:', $locale), 'cli.warning');
- $c->writeln($dir);
+ $c->writeln($targetdir);
$c->writeln();
continue;
}
}
/* Convert to unix linebreaks. */
- $pofile = $dirs[$i] . DS . 'po' . DS . $locale . '.po';
- $content = file_get_contents($pofile);
- $content = str_replace("\r", '', $content);
- $fp = fopen($pofile, 'wb');
- fwrite($fp, $content);
- fclose($fp);
+ $content = str_replace("\r", '', file_get_contents($pofile));
+ file_put_contents($pofile, $content);
/* Remember update date. */
$last_update = preg_match(
? $matches[1] : '';
/* Check PO file sanity. */
- $sh = $GLOBALS['msgfmt'] . " --check \"$pofile\"$redir_err";
+ $sh = $GLOBALS['msgfmt'] . " --check --output-file=/dev/null \"$pofile\" $redir_err";
if ($debug || $test) {
$c->writeln('Executing:');
$c->writeln($sh);
}
/* Compile MO file. */
- $sh = $GLOBALS['msgfmt'] . ' --statistics -o "' . $dir . DS . $apps[$i] . '.mo" ';
+ $sh = $GLOBALS['msgfmt'] . ' --statistics -o "' . $targetdir . DS . $apps[$i] . '.mo" ';
if ($apps[$i] != 'horde') {
$horde_po = $dirs[$horde] . DS . 'po' . DS . $locale . '.po';
if (!is_readable($horde_po)) {
/* Merge translation into compendium. */
if (!empty($compendium)) {
printf('Merging the PO file for %s to the compendium... ', $c->bold($apps[$i]));
- if (!empty($dir) && substr($dir, -1) != DS) {
- $dir .= DS;
+ if (!empty($targetdir) && substr($targetdir, -1) != DS) {
+ $targetdir .= DS;
}
$sh = $GLOBALS['msgcat'] . " --sort-output \"$compendium\" \"$pofile\" > \"$compendium.tmp\"";
if (!$debug) {
continue;
}
$c->writeln(sprintf('Cleaning up PO files for module %s...', $c->bold($apps[$i])));
+ $po = $dirs[$i] . DS . 'locale' . DS . '%s' . DS . 'LC_MESSAGES' .DS . $apps[$i] . '.po';
if (empty($lang)) {
$langs = get_languages($dirs[$i]);
} else {
- if (!file_exists($dirs[$i] . DS . 'po' . DS . $lang . '.po')) {
+ if (!file_exists(sprintf($po, $lang))) {
$c->writeln('Skipped...');
$c->writeln();
continue;
}
foreach ($langs as $locale) {
$c->writeln(sprintf('Cleaning up locale %s... ', $c->bold($locale)));
- $pofile = $dirs[$i] . DS . 'po' . DS . $locale . '.po';
+ $pofile = sprintf($po, $locale);
$sh = $GLOBALS['msgattrib'] . ($keep_untranslated ? '' : ' --translated') . " --no-obsolete --force-po \"$pofile\" > \"$pofile.tmp\"";
if (!$debug) {
$sh .= $silence;
$files = array_merge($files, strip_horde(search_file('^[a-z]{2}_[A-Z]{2}', $dirs[$i] . DS . 'locale', true)));
}
} else {
- if ($help_only) {
- if (!file_exists($dirs[$i] . DS . 'locale' . DS . $lang . DS . 'help.xml')) {
- continue;
- }
- } else {
- if (!file_exists($dirs[$i] . '/po/' . $lang . '.po')) {
- continue;
- }
- $files[] = strip_horde($dirs[$i] . DS . 'po' . DS . $lang . '.po');
+ if ($help_only &&
+ !file_exists($dirs[$i] . DS . 'locale' . DS . $lang . DS . 'help.xml')) {
+ continue;
}
$files[] = strip_horde($dirs[$i] . DS . 'locale' . DS . $lang);
}
$c->writeln('Adding new files to repository:');
$add_files = array();
foreach ($files as $file) {
- if (strstr($file, 'locale') || strstr($file, '.po')) {
+ if (strstr($file, 'locale')) {
$add_files[] = $file;
$c->writeln($file);
}
if (!$help_only) {
foreach ($files as $file) {
if (strstr($file, 'locale')) {
- $add = $file . DS . 'LC_MESSAGES' . DS . '*.mo';
- $add_files[] = $add;
- $c->writeln($add);
+ $c->writeln($add_files[] = $file . DS . 'LC_MESSAGES' . DS . '*.po');
+ $c->writeln($add_files[] = $file . DS . 'LC_MESSAGES' . DS . '*.mo');
}
}
}