mirror of
https://github.com/silverstripe/silverstripe-installer
synced 2024-10-22 15:05:33 +00:00
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
This commit is contained in:
parent
17303c6e9f
commit
04cf94ff76
23
build.xml
23
build.xml
@ -406,6 +406,19 @@ Your friendly automated release script.
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="translations-staging-setup">
|
<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 checkout master" dir="${module}" checkreturn="true" />
|
||||||
<exec command="git fetch origin" dir="${module}" checkreturn="true" />
|
<exec command="git fetch origin" dir="${module}" checkreturn="true" />
|
||||||
<exec command="git branch -D translation-staging" 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>
|
<then>
|
||||||
<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
|
<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 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>
|
</then>
|
||||||
</if>
|
</if>
|
||||||
</target>
|
</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 lang/*" dir="${module}" passthru="true" checkreturn="true" />
|
||||||
<exec command="git add javascript/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 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>
|
</then>
|
||||||
</if>
|
</if>
|
||||||
<exec command="git checkout master" dir="${module}" checkreturn="true" />
|
<exec command="git checkout master" dir="${module}" checkreturn="true" />
|
||||||
@ -465,9 +478,9 @@ Your friendly automated release script.
|
|||||||
|
|
||||||
<target name="translations-sync"
|
<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.">
|
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="framework,cms" param="module" target="translations-update-git-masterfile" />
|
||||||
<foreach list="cms" param="module" target="translations-update-gl-masterfile" />
|
<foreach list="framework,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-gl-contribs" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -156,11 +156,13 @@ class UpdateTranslationsTask extends SilverStripeBuildTask {
|
|||||||
// can't easily change to that format for backwards compat reasons, so we need to convert.
|
// 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.
|
// 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".
|
// 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);
|
$content = file_get_contents($file);
|
||||||
preg_match('/^([\w-_]*):/', $content, $matches);
|
preg_match($localeRegex, $content, $matches);
|
||||||
$locale = $matches[1];
|
$locale = $matches[1];
|
||||||
$locale = str_replace('-', '_', $locale);
|
$locale = str_replace('-', '_', $locale);
|
||||||
$locale = str_replace(':', '', $locale);
|
$locale = str_replace(':', '', $locale);
|
||||||
|
$content = preg_replace($localeRegex, $locale . ':', $content);
|
||||||
|
|
||||||
// Convert faulty multiline double quoted string YAML
|
// Convert faulty multiline double quoted string YAML
|
||||||
// to block format, in order to allow the YAML Parser to open it later
|
// to block format, in order to allow the YAML Parser to open it later
|
||||||
@ -191,11 +193,11 @@ class UpdateTranslationsTask extends SilverStripeBuildTask {
|
|||||||
|
|
||||||
// Parse YML as a sanity check,
|
// Parse YML as a sanity check,
|
||||||
// and reorder alphabetically by key to ensure consistent diffs.
|
// 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 dirname(__FILE__) . '/../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 dirname(__FILE__) . '/../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/sfYamlDumper.php';
|
||||||
$yamlHandler = new sfYaml();
|
$yamlHandler = new sfYaml();
|
||||||
$yml = $yamlHandler->parse($content);
|
$yml = $yamlHandler->load($content);
|
||||||
if(isset($yml[$locale]) && is_array($yml[$locale])) {
|
if(isset($yml[$locale]) && is_array($yml[$locale])) {
|
||||||
ksort($yml[$locale]);
|
ksort($yml[$locale]);
|
||||||
foreach($yml[$locale] as $k => &$v) {
|
foreach($yml[$locale] as $k => &$v) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user