Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored June 25, 2012
23  build.xml
@@ -406,6 +406,19 @@ Your friendly automated release script.
406 406
 	</target>
407 407
 
408 408
 	<target name="translations-staging-setup">
  409
+		<propertyprompt propertyName="module" 
  410
+			promptText="Module name?"
  411
+			useExistingValue="true" />
  412
+		<propertyprompt propertyName="getlocalization.${module}.project" 
  413
+			promptText="getlocalization project"
  414
+			useExistingValue="true" />
  415
+		<propertyprompt propertyName="getlocalization.${module}.user" 
  416
+			promptText="getlocalization username"
  417
+			useExistingValue="true" />
  418
+		<propertyprompt propertyName="getlocalization.${module}.password" 
  419
+			promptText="getlocalization password"
  420
+			useExistingValue="true" />
  421
+
409 422
 		<exec command="git checkout master" dir="${module}" checkreturn="true" />
410 423
 		<exec command="git fetch origin" dir="${module}" checkreturn="true" />
411 424
 		<exec command="git branch -D translation-staging" dir="${module}" checkreturn="true" />
@@ -428,7 +441,7 @@ Your friendly automated release script.
428 441
 			<then>
429 442
 				<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
430 443
 				<exec command="git commit -m 'MINOR Updated translations master'" dir="${module}" passthru="true" checkreturn="true" />
431  
-				<exec command="git merge --force origin/master" dir="${module}" checkreturn="true" />
  444
+				<exec command="git merge origin/master" dir="${module}" checkreturn="true" />
432 445
 			</then>
433 446
 		</if>
434 447
 	</target>
@@ -456,7 +469,7 @@ Your friendly automated release script.
456 469
 				<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
457 470
 				<exec command="git add javascript/lang/*" dir="${module}" passthru="true" checkreturn="true" />
458 471
 				<exec command="git commit -m 'MINOR Updated translations'" dir="${module}" passthru="true" checkreturn="true" />
459  
-				<exec command="git push origin/translation-staging" dir="${module}" checkreturn="true" />
  472
+				<exec command="git push origin translation-staging" dir="${module}" checkreturn="true" />
460 473
 			</then>
461 474
 		</if>
462 475
 		<exec command="git checkout master" dir="${module}" checkreturn="true" />
@@ -465,9 +478,9 @@ Your friendly automated release script.
465 478
 
466 479
 	<target name="translations-sync" 
467 480
 		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.">
468  
-		<foreach list="cms" param="module" target="translations-update-git-masterfile" />
469  
-		<foreach list="cms" param="module" target="translations-update-gl-masterfile" />
470  
-		<foreach list="cms" param="module" target="translations-update-gl-contribs" />
  481
+		<foreach list="framework,cms" param="module" target="translations-update-git-masterfile" />
  482
+		<foreach list="framework,cms" param="module" target="translations-update-gl-masterfile" />
  483
+		<foreach list="framework,cms" param="module" target="translations-update-gl-contribs" />
471 484
 	</target>
472 485
 
473 486
 </project>
12  tools/UpdateTranslationsTask.php
@@ -156,11 +156,13 @@ protected function processYmlFile($file) {
156 156
 		// can't easily change to that format for backwards compat reasons, so we need to convert.
157 157
 		// The passed in file name doesn't really matter here, only the contained locale.
158 158
 		// By convention, the first line in the YAML file is always the locale used, as a YAML "root key".
  159
+		$localeRegex = '/^([\w-_]*):/';
159 160
 		$content = file_get_contents($file);
160  
-		preg_match('/^([\w-_]*):/', $content, $matches);
  161
+		preg_match($localeRegex, $content, $matches);
161 162
 		$locale = $matches[1];
162 163
 		$locale = str_replace('-', '_', $locale);
163 164
 		$locale = str_replace(':', '', $locale);
  165
+		$content = preg_replace($localeRegex, $locale . ':', $content);
164 166
 		
165 167
 		// Convert faulty multiline double quoted string YAML
166 168
 		// to block format, in order to allow the YAML Parser to open it later
@@ -191,11 +193,11 @@ protected function processYmlFile($file) {
191 193
 
192 194
 		// Parse YML as a sanity check,
193 195
 		// and reorder alphabetically by key to ensure consistent diffs.
194  
-		require_once '../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYaml.php';
195  
-		require_once '../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlParser.php';
196  
-		require_once '../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlDumper.php';
  196
+		require_once dirname(__FILE__) . '/../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYaml.php';
  197
+		require_once dirname(__FILE__) . '/../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlParser.php';
  198
+		require_once dirname(__FILE__) . '/../framework/thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlDumper.php';
197 199
 		$yamlHandler = new sfYaml();
198  
-		$yml = $yamlHandler->parse($content);
  200
+		$yml = $yamlHandler->load($content);
199 201
 		if(isset($yml[$locale]) && is_array($yml[$locale])) {
200 202
 			ksort($yml[$locale]);
201 203
 			foreach($yml[$locale] as $k => &$v) {

0 notes on commit 04cf94f

Please sign in to comment.
Something went wrong with that request. Please try again.