#1627006-84: Collect project information for translation update suggests possible reusing of code for version name parsing.

See: core/modules/locale/locale.compare.inc

Comments

YesCT’s picture

Sutharsan points out: This code tries to do a version fallback, a thing that Update module does not provide.

Here are some code fragments to get an idea of the parsing:

+++ b/core/modules/locale/locale.compare.incundefined

@@ -107,6 +113,7 @@ function locale_translation_build_projects() {
foreach ($project_updates[$name]['releases'] as $project_release) {
// The first release with the same major release number which is not a
// dev release is the one. Releases are sorted the most recent first.
+ // @todo http://drupal.org/node/1774024 Make a helper function.
if ($project_release['version_major'] == $matches[1] &&
(!isset($project_release['version_extra']) || $project_release['version_extra'] != 'dev')) {
$release = $project_release;

@@ -114,6 +121,7 @@ function locale_translation_build_projects() {
}
}
}
+ // HEAD versions are for module maintainers and should not be used.
elseif ($name == "drupal" || preg_match("/HEAD/", $data['info']['version'], $matches)) {
// Pick latest available release.
$release = array_shift($project_updates[$name]['releases']);

@@ -132,7 +140,7 @@ function locale_translation_build_projects() {
// A project can provide the path and filename pattern to download the
// gettext file. Use the default if not.
'server_pattern' => isset($data['info']['interface translation server pattern']) ? $data['info']['interface translation server pattern'] : $default_server['pattern'],
- 'status' => $data['project_status'] ? 1 : 0,
+ 'status' => !empty($data['project_status']) ? 1 : 0,
);

Sutharsan’s picture

Gábor Hojtsy’s picture