Skip to content
Snippets Groups Projects
Commit ba986e11 authored by Jared Hancock's avatar Jared Hancock
Browse files

i18n: Add -b option to support build packs from Crowdin branches

parent 95c9fbf5
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,8 @@ class i18n_Compiler extends Module {
'action' => 'store_true', 'help' => 'Compress PHAR with zlib'),
'bzip2' => array('-j', '--bzip2', 'default' => false,
'action' => 'store_true', 'help' => 'Compress PHAR with bzip2'),
'branch' => array('-b', '--branch', 'help' => 'Use a Crowdin branch
(other than the root)'),
);
var $epilog = "Note: If updating DNS, you will need to set
......@@ -175,16 +177,27 @@ class i18n_Compiler extends Module {
$po_file = false;
$branch = false;
if ($options['branch'])
$branch = trim($options['branch'], '/') . '/';
for ($i=0; $i<$zip->numFiles; $i++) {
$info = $zip->statIndex($i);
if ($branch && strpos($info['name'], $branch) !== 0) {
// Skip files not part of the named branch
continue;
}
$contents = $zip->getFromIndex($i);
if (!$contents)
continue;
if (strpos($info['name'], '/messages.po') !== false) {
if (fnmatch('*/messages*.po', $info['name']) !== false) {
$po_file = $contents;
// Don't add the PO file as-is to the PHAR file
continue;
}
elseif (!$branch && !file_exists(I18N_DIR . 'en_US/' . $info['name'])) {
// Skip files in (other) branches
continue;
}
$phar->addFromString($info['name'], $contents);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment