Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR Getlocalization phing target fixes

 - Fixed combined locale setting in generated files (broke en_GB etc)
 - Prompting for property names
 - Fixed YAML parsing and git commands
  • Loading branch information...
commit 04cf94ff76d6384a287758d16c69f04b1b6034d1 1 parent 17303c6
Ingo Schommer chillu authored
Showing with 25 additions and 10 deletions.
  1. +18 −5 build.xml
  2. +7 −5 tools/UpdateTranslationsTask.php
23 build.xml
View
@@ -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" />
@@ -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>
@@ -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" />
@@ -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 tools/UpdateTranslationsTask.php
View
@@ -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
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.