Skip to content

Commit

Permalink
MINOR Getlocalization phing target fixes
Browse files Browse the repository at this point in the history
 - Fixed combined locale setting in generated files (broke en_GB etc)
 - Prompting for property names
 - Fixed YAML parsing and git commands
  • Loading branch information
chillu committed Jun 25, 2012
1 parent 17303c6 commit 04cf94f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
23 changes: 18 additions & 5 deletions build.xml
Expand Up @@ -406,6 +406,19 @@ Your friendly automated release script.
</target>

<target name="translations-staging-setup">
<propertyprompt propertyName="module"
promptText="Module name?"
useExistingValue="true" />
<propertyprompt propertyName="getlocalization.${module}.project"
promptText="getlocalization project"
useExistingValue="true" />
<propertyprompt propertyName="getlocalization.${module}.user"
promptText="getlocalization username"
useExistingValue="true" />
<propertyprompt propertyName="getlocalization.${module}.password"
promptText="getlocalization password"
useExistingValue="true" />

<exec command="git checkout master" dir="${module}" checkreturn="true" />
<exec command="git fetch origin" dir="${module}" checkreturn="true" />
<exec command="git branch -D translation-staging" dir="${module}" checkreturn="true" />
Expand All @@ -428,7 +441,7 @@ Your friendly automated release script.
<then>
<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git commit -m 'MINOR Updated translations master'" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git merge --force origin/master" dir="${module}" checkreturn="true" />
<exec command="git merge origin/master" dir="${module}" checkreturn="true" />
</then>
</if>
</target>
Expand Down Expand Up @@ -456,7 +469,7 @@ Your friendly automated release script.
<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git add javascript/lang/*" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git commit -m 'MINOR Updated translations'" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git push origin/translation-staging" dir="${module}" checkreturn="true" />
<exec command="git push origin translation-staging" dir="${module}" checkreturn="true" />
</then>
</if>
<exec command="git checkout master" dir="${module}" checkreturn="true" />
Expand All @@ -465,9 +478,9 @@ Your friendly automated release script.

<target name="translations-sync"
description="Wrapper task to handle updating translations and master files, using the getlocalization.com API, committing to a specialized branch in the working copy and pushing to the origin repository.">
<foreach list="cms" param="module" target="translations-update-git-masterfile" />
<foreach list="cms" param="module" target="translations-update-gl-masterfile" />
<foreach list="cms" param="module" target="translations-update-gl-contribs" />
<foreach list="framework,cms" param="module" target="translations-update-git-masterfile" />
<foreach list="framework,cms" param="module" target="translations-update-gl-masterfile" />
<foreach list="framework,cms" param="module" target="translations-update-gl-contribs" />
</target>

</project>
12 changes: 7 additions & 5 deletions tools/UpdateTranslationsTask.php
Expand Up @@ -156,11 +156,13 @@ protected function processYmlFile($file) {
// can't easily change to that format for backwards compat reasons, so we need to convert.
// The passed in file name doesn't really matter here, only the contained locale.
// By convention, the first line in the YAML file is always the locale used, as a YAML "root key".
$localeRegex = '/^([\w-_]*):/';
$content = file_get_contents($file);
preg_match('/^([\w-_]*):/', $content, $matches);
preg_match($localeRegex, $content, $matches);
$locale = $matches[1];
$locale = str_replace('-', '_', $locale);
$locale = str_replace(':', '', $locale);
$content = preg_replace($localeRegex, $locale . ':', $content);

// Convert faulty multiline double quoted string YAML
// to block format, in order to allow the YAML Parser to open it later
Expand Down Expand Up @@ -191,11 +193,11 @@ protected function processYmlFile($file) {

// Parse YML as a sanity check,
// and reorder alphabetically by key to ensure consistent diffs.
require_once '../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYaml.php';
require_once '../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlParser.php';
require_once '../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlDumper.php';
require_once dirname(__FILE__) . '/../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYaml.php';
require_once dirname(__FILE__) . '/../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlParser.php';
require_once dirname(__FILE__) . '/../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlDumper.php';
$yamlHandler = new sfYaml();
$yml = $yamlHandler->parse($content);
$yml = $yamlHandler->load($content);
if(isset($yml[$locale]) && is_array($yml[$locale])) {
ksort($yml[$locale]);
foreach($yml[$locale] as $k => &$v) {
Expand Down

0 comments on commit 04cf94f

Please sign in to comment.