blob: b63f6428e57426883dfeef16b09100ea1f02f747 [file] [log] [blame]
gobrien1a8e02f2008-01-30 01:46:26 +00001<?php
2/*******************************************************************************
3 * Copyright (c) 2008 Eclipse Foundation and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Eclipse Foundation - Initial API and implementation
droy133e7462008-05-13 17:37:24 +000011 * Motoki MORT mori-m@mxa.nes.nec.co.jp - patch, bug 227366
kitlo9c7c62a2008-10-05 16:05:19 +000012 * Kit Lo (IBM) - patch, bug 217339, generate pseudo translations language packs
13 * Kit Lo (IBM) - patch, bug 234430, need language packs by means of other than update site
kitlo7f522672008-10-21 14:15:54 +000014 * Kit Lo (IBM) - patch, bug 251536, newline char missing after copyright comment on first line
kitlo1173dbd2008-10-21 15:58:36 +000015 * Kit Lo (IBM) - patch, bug 238580, language packs should not include strings that are marked "non-translatable"
kitlo5c9da712008-10-27 12:45:40 +000016 * Kit Lo (IBM) - patch, bug 252140, Illegal token characters in babel fragment names
atoulmedbda4272009-01-20 06:04:22 +000017 * Antoine Toulme (Intalio, Inc) - patch, bug 256430, Fragments with no host jeopardize Eclipse installation
kitlo47df0c62009-01-22 15:16:18 +000018 * Kit Lo (IBM) - patch, bug 261739, Inconsistent use of language names
kitlo8d7c0532009-03-14 23:57:49 +000019 * Sean Flanigan (Red Hat) - patch, bug 261584, wrong output folder
kitlo58d8a5a2008-09-24 20:08:44 +000020 *******************************************************************************/
gobrien1a8e02f2008-01-30 01:46:26 +000021
22/*
kitlo58d8a5a2008-09-24 20:08:44 +000023 * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs
gobrien1a8e02f2008-01-30 01:46:26 +000024 */
atoulme3fa5f5c2009-01-20 21:26:16 +000025define("METADATA_GENERATOR_LOCATION", "/home/genie/eclipse"); // you might want to read this value from a config file. Not sure yet.
gobrienb854dcb2008-01-30 18:50:45 +000026
kitlo9c7c62a2008-10-05 16:05:19 +000027ini_set("memory_limit", "64M");
atoulme3ac52612009-02-02 13:14:39 +000028require(dirname(__FILE__) . "/../system/backend_functions.php");
atoulme12882d52009-01-26 18:39:17 +000029require(dirname(__FILE__) . "/../system/dbconnection.class.php");
kitlo399df202008-09-30 15:32:25 +000030$dbc = new DBConnection();
31$dbh = $dbc->connect();
droyb6e25c72008-07-18 13:01:13 +000032
atoulme3ac52612009-02-02 13:14:39 +000033$work_dir = $addon->callHook('babel_working');
atoulme12882d52009-01-26 18:39:17 +000034
atoulme3ac52612009-02-02 13:14:39 +000035global $addon;
36$context = $addon->callHook('context');
gobrienb854dcb2008-01-30 18:50:45 +000037
kitlo9c7c62a2008-10-05 16:05:19 +000038$work_context_dir = $work_dir . $context . "/";
39$tmp_dir = $work_context_dir . "tmp/";
40$babel_language_packs_dir = $work_context_dir . "babel_language_packs/";
41$output_dir = $work_context_dir . "output/";
atoulme3ac52612009-02-02 13:14:39 +000042$source_files_dir = dirname(__FILE__) . "/source_files_for_generate/";
gobrienb854dcb2008-01-30 18:50:45 +000043
droydfd5d622008-11-10 20:16:39 +000044# Language pack URL leader, to enable mirrors on download.eclipse.org
45$language_pack_leader = "";
46if($context == "live") {
47 $language_pack_leader = "http://www.eclipse.org/downloads/download.php?r=1&file=/technology/babel/babel_language_packs/";
48}
49
gobrien1a8e02f2008-01-30 01:46:26 +000050$leader = ". . ";
kitlo58d8a5a2008-09-24 20:08:44 +000051$timestamp = date("Ymdhis");
gobrien1a8e02f2008-01-30 01:46:26 +000052
droyd157aac2008-10-07 21:14:33 +000053$rm_command = "rm -rf $work_dir" . "*";
54exec($rm_command);
droy082976e2008-10-07 21:02:23 +000055exec("mkdir -p $output_dir");
56
kitlo9c7c62a2008-10-05 16:05:19 +000057/*
58 * Create language pack links file
59 */
60exec("mkdir -p $babel_language_packs_dir");
droydfd5d622008-11-10 20:16:39 +000061$language_pack_links_file = fopen("${babel_language_packs_dir}index.php", "w");
62fwrite($language_pack_links_file, "<?php\n\$pageTitle = \"Babel Language Packs\";\n");
droy4bef3dc2008-11-10 20:55:06 +000063fwrite($language_pack_links_file, "include \$_SERVER['DOCUMENT_ROOT'] . '/eclipse.org-common/themes/Phoenix/header.php';\n");
droydfd5d622008-11-10 20:16:39 +000064fwrite($language_pack_links_file, "?>\n");
droy03d5c462008-11-10 21:07:01 +000065fwrite($language_pack_links_file, "<div id='maincontent'><div id='midcolumn'>\n");
droydfd5d622008-11-10 20:16:39 +000066fwrite($language_pack_links_file, "\n\t<h1>Babel Language Packs</h1>" .
droyeb6d9b22008-11-24 18:42:28 +000067 "\n\t<h2>Build ID: $timestamp</h2>" .
68 "\n\t<p>The following language packs are based on the community translations entered into the <a href='http://babel.eclipse.org/'>Babel Translation Tool</a>, and may not be complete or entirely accurate. If you find missing or incorrect translations, please use the <a href='http://babel.eclipse.org/'>Babel Translation Tool</a> to update them." .
69 "\n\tAll downloads are provided under the terms and conditions of the <a href='http://www.eclipse.org/legal/epl/notice.php'>Eclipse Foundation Software User Agreement</a> unless otherwise specified.</p>");
droy0b08d292008-05-28 15:18:11 +000070
kitlo58d8a5a2008-09-24 20:08:44 +000071echo "Generating update site\n";
droyeb6d9b22008-11-24 18:42:28 +000072$train_result = mysql_query("SELECT DISTINCT train_id FROM release_train_projects ORDER BY train_id DESC");
kitlo58d8a5a2008-09-24 20:08:44 +000073while (($train_row = mysql_fetch_assoc($train_result)) != null) {
74 $train_id = $train_row['train_id'];
75 $train_version = "3.4.0";
76 if (strcmp($train_id, "europa") == 0) {
77 $train_version = "3.3.0";
droy0b08d292008-05-28 15:18:11 +000078 }
kitlo9c7c62a2008-10-05 16:05:19 +000079 $train_version_timestamp = "$train_version.v$timestamp";
80 $site_xml = "";
kitlo58d8a5a2008-09-24 20:08:44 +000081
82 $output_dir_for_train = $output_dir . $train_row['train_id'] . "/";
83 exec("mkdir $output_dir_for_train");
84 exec("mkdir ${output_dir_for_train}features/");
85 exec("mkdir ${output_dir_for_train}plugins/");
86
kitlo9c7c62a2008-10-05 16:05:19 +000087 fwrite($language_pack_links_file, "\n\t<h3>Release Train: $train_id</h3>\n\t<ul>");
88
kitlo47df0c62009-01-22 15:16:18 +000089 $language_result = mysql_query("SELECT language_id, iso_code, IF(locale <> '', CONCAT(CONCAT(CONCAT(name, ' ('), locale), ')'), name) as name, is_active, IF(language_id = 1,1,0) AS sorthack FROM languages ORDER BY sorthack, name ASC");
kitlo9c7c62a2008-10-05 16:05:19 +000090 while (($language_row = mysql_fetch_assoc($language_result)) != null) {
droy0b08d292008-05-28 15:18:11 +000091 $language_name = $language_row['name'];
kitlo58d8a5a2008-09-24 20:08:44 +000092 $language_iso = $language_row['iso_code'];
kitlo58d8a5a2008-09-24 20:08:44 +000093 $language_id = $language_row['language_id'];
94 if (strcmp($language_iso, "en") == 0) {
95 $language_iso = "en_AA";
96 $language_name = "Pseudo Translations";
97 }
kitlo9c7c62a2008-10-05 16:05:19 +000098
99 $site_xml .= "\n\t<category-def name=\"Babel Language Packs in $language_name\" label=\"Babel Language Packs in $language_name\">";
100 $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>";
101 $site_xml .= "\n\t</category-def>";
102
103 fwrite($language_pack_links_file, "\n\t<h4>Language: $language_name</h4>\n\t<ul>");
104
kitlo58d8a5a2008-09-24 20:08:44 +0000105 echo "${leader}Generating language pack for $train_id - $language_name ($language_iso) (language_id=" . $language_id . ")\n";
106
gobrien1a8e02f2008-01-30 01:46:26 +0000107 /*
droy0b08d292008-05-28 15:18:11 +0000108 * Determine which plug-ins need to be in this language pack.
gobrien1a8e02f2008-01-30 01:46:26 +0000109 */
kitlo58d8a5a2008-09-24 20:08:44 +0000110 if (strcmp($language_iso, "en_AA") == 0) {
111 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
112 FROM files AS f
113 INNER JOIN strings AS s ON f.file_id = s.file_id
114 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
115 WHERE f.is_active
116 AND v.train_id = '" . $train_row['train_id'] . "'");
kitlo58d8a5a2008-09-24 20:08:44 +0000117 } else {
118 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
119 FROM files AS f
120 INNER JOIN strings AS s ON f.file_id = s.file_id
121 INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active)
122 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
123 WHERE t.language_id = " . $language_id . "
124 AND f.is_active
125 AND v.train_id = '" . $train_row['train_id'] . "'");
126 }
127
droy0b08d292008-05-28 15:18:11 +0000128 $plugins = array();
kitlo9c7c62a2008-10-05 16:05:19 +0000129 $projects = array();
130 $project_versions = array();
131 $pseudo_translations_indexes = array();
kitlo58d8a5a2008-09-24 20:08:44 +0000132 while (($file_row = mysql_fetch_assoc($file_result)) != null) {
133 # save original filename
134 $file_row['origname'] = $file_row['name'];
135
droy02c430a2008-06-02 19:42:08 +0000136 # strip useless CVS structure before the plugin name (bug 221675 c14):
137 $pattern = '/^([a-zA-Z0-9\/_-])+\/([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)(.*)\.properties$/i';
138 $replace = '${2}.${3}${4}.properties';
139 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000140
droy02c430a2008-06-02 19:42:08 +0000141 # strip source folder (bug 221675) (org.eclipse.plugin/source_folder/org/eclipse/plugin)
kitlo8d7c0532009-03-14 23:57:49 +0000142 /*
143 $pattern =
144 '/^
145 ([a-zA-Z0-9_-]+)\. # \1 org.
146 ([a-zA-Z0-9_-]+)\. # \2 eclipse.
147 ([a-zA-Z0-9\._-]+) # \3 datatools.connectivity
148 (.*)\/ # \4 \/plugins\/
149 (\1) # \5 org
150 ([\.\/]) # \6 .
151 (\2) # \7 eclipse
152 ([\.\/]) # \8 .
153 (.*) # \9 datatools.connectivity.ui\/plugin
154 \.properties # .properties
155 $/ix
156 ';
droy02c430a2008-06-02 19:42:08 +0000157 $replace = '${1}.${2}.${3}/${5}${6}${7}${8}${9}.properties';
kitlo8d7c0532009-03-14 23:57:49 +0000158 */
159
160 # fix output folder (bug 261584)
161 $pattern =
162 '/^
163 (.*\/)? # \1 optional outer directories
164 ([a-z]+) # \2 org|com|etc
165 [.] # dot
166 ([^\/]+) # \3 plugin id except org.|com.
167 \/ # slash
168 (.*?\/)? # \4 optional src\/, src\/main\/ etc
169 # \5 resource path (pathname inside resulting jar)
170 # (a) within a org|com directory, or
171 # (b) in plugin root dir.
172 (\2\/.*[.]properties| # org|com\/anything.properties
173 [^\/]+[.]properties) # eg plugin.properties
174 $/ix';
175 $replace = '$2.$3/$5';
176
droy0b08d292008-05-28 15:18:11 +0000177 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000178
179 if (preg_match("/^([a-zA-Z0-9\.]+)\/(.*)$/", $file_row['name'], $matches)) {
droy0b08d292008-05-28 15:18:11 +0000180 $file_row['subname'] = $matches[2];
181 $plugins[$matches[1]][] = $file_row;
182 } else {
183 echo " WARNING: no plug-in name found in file " . $file_row['file_id'] . " \"" . $file_row['name'] . "\"\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000184 }
droy0b08d292008-05-28 15:18:11 +0000185 }
kitlo58d8a5a2008-09-24 20:08:44 +0000186
droy0b08d292008-05-28 15:18:11 +0000187 /*
188 * Generate one plug-in fragment for each plug-in
189 */
kitlo58d8a5a2008-09-24 20:08:44 +0000190 foreach ($plugins as $plugin_name => $plugin_row) {
191 echo "${leader}${leader}Generating plug-in fragment $plugin_name\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000192 /*
droy0b08d292008-05-28 15:18:11 +0000193 * Clean and create the temporary directory
gobrien1a8e02f2008-01-30 01:46:26 +0000194 */
kitlo58d8a5a2008-09-24 20:08:44 +0000195 if (file_exists($tmp_dir)) {
196 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000197 } else {
kitlo58d8a5a2008-09-24 20:08:44 +0000198 exec("mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000199 }
gobrien1a8e02f2008-01-30 01:46:26 +0000200 /*
droy0b08d292008-05-28 15:18:11 +0000201 * Generate each *.properties file
gobrien1a8e02f2008-01-30 01:46:26 +0000202 */
droy0b08d292008-05-28 15:18:11 +0000203 foreach ($plugin_row as $properties_file) {
204 /*
205 * Convert the filename to *_lang.properties, e.g., foo_fr.properties
206 */
207 $filename = $properties_file['subname'];
kitlo58d8a5a2008-09-24 20:08:44 +0000208 if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) {
droy0b08d292008-05-28 15:18:11 +0000209 $filename = $matches[1] . '_' . $language_iso . '.properties';
gobrien1a8e02f2008-01-30 01:46:26 +0000210 }
kitlo58d8a5a2008-09-24 20:08:44 +0000211 echo "${leader}${leader}${leader}Generating properties file $filename (file_id=" . $properties_file['file_id'] . ")\n";
droy0b08d292008-05-28 15:18:11 +0000212 /*
213 * Create any needed sub-directories
214 */
kitlo58d8a5a2008-09-24 20:08:44 +0000215 $fullpath = $tmp_dir . $filename;
216 preg_match("/^((.*)\/)?(.+?)$/", $fullpath, $matches);
217 exec("mkdir -p \"" . $matches[1] . "\"");
droy0b08d292008-05-28 15:18:11 +0000218 /*
219 * Start writing to the file
220 */
kitlo58d8a5a2008-09-24 20:08:44 +0000221 $outp = fopen($fullpath, "w");
kitloc42941d2008-11-20 15:33:00 +0000222 fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/");
kitlo58d8a5a2008-09-24 20:08:44 +0000223 if (strcmp($language_iso, "en_AA") == 0) {
224 $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] .
225 " AND is_active AND non_translatable = 0";
226 $strings_result = mysql_query($sql);
227 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo9c7c62a2008-10-05 16:05:19 +0000228 fwrite($outp, "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] .
229 ":" . $strings_row['value']);
kitlo58d8a5a2008-09-24 20:08:44 +0000230
231 $value = htmlspecialchars($strings_row['value']);
232 if (strlen($value) > 100) {
233 $value = substr($value, 0, 100) . " ...";
234 }
kitlo9c7c62a2008-10-05 16:05:19 +0000235 $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" .
236 $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" .
237 $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" .
238 $properties_file['project_id'] . $strings_row['string_id'] . "</a>&nbsp;" . $value . "</li>";
kitlo58d8a5a2008-09-24 20:08:44 +0000239 }
240 } else {
241 $sql = "SELECT
242 strings.name AS 'key',
243 strings.value AS orig,
244 translations.value AS trans
droy0b08d292008-05-28 15:18:11 +0000245 FROM strings, translations
246 WHERE strings.string_id = translations.string_id
droy0b08d292008-05-28 15:18:11 +0000247 AND strings.file_id = " . $properties_file['file_id'] . "
kitlo1173dbd2008-10-21 15:58:36 +0000248 AND strings.is_active
249 AND strings.non_translatable = 0
250 AND translations.language_id = " . $language_id . "
kitlo58d8a5a2008-09-24 20:08:44 +0000251 AND translations.is_active";
252 $strings_result = mysql_query($sql);
253 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo7f522672008-10-21 14:15:54 +0000254 fwrite($outp, "\n" . $strings_row['key'] . "=");
kitlo9c7c62a2008-10-05 16:05:19 +0000255 # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "=";
kitlo58d8a5a2008-09-24 20:08:44 +0000256 if ($strings_row['trans']) {
257 # json_encode returns the string with quotes fore and aft. Need to strip them.
258 # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
259 # $tr_string = str_replace('\\\\', '\\', $tr_string);
260 $tr_string = toescapedunicode($strings_row['trans']);
261 fwrite($outp, $tr_string);
262 # echo $strings_row['trans'];
263 } else {
264 fwrite($outp, $strings_row['orig']);
265 }
droy0b08d292008-05-28 15:18:11 +0000266 }
droy0b08d292008-05-28 15:18:11 +0000267 }
268 /*
269 * Finish the properties file
270 */
kitlo58d8a5a2008-09-24 20:08:44 +0000271 fclose($outp);
272 echo "${leader}${leader}${leader}Completed properties file $filename\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000273 }
274 /*
droy0b08d292008-05-28 15:18:11 +0000275 * Copy in the various legal files
gobrien1a8e02f2008-01-30 01:46:26 +0000276 */
kitlo9c7c62a2008-10-05 16:05:19 +0000277 exec("cp ${source_files_dir}about.html $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000278 /*
279 * Generate the META-INF/MANIFEST.MF file
280 */
281 $parent_plugin_id = $plugin_name;
kitlo9c7c62a2008-10-05 16:05:19 +0000282 $project_id = $properties_file['project_id'];
kitlo5c9da712008-10-27 12:45:40 +0000283 $fragment_id = "$parent_plugin_id.nl_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000284 $fragment_filename = "${fragment_id}_$train_version_timestamp.jar";
kitlo58d8a5a2008-09-24 20:08:44 +0000285
droy0b08d292008-05-28 15:18:11 +0000286 $plugins[$plugin_name]['id'] = $fragment_id;
kitlo9c7c62a2008-10-05 16:05:19 +0000287 $plugins[$plugin_name]['version'] = $train_version_timestamp;
kitlo58d8a5a2008-09-24 20:08:44 +0000288
289 exec("mkdir $tmp_dir/META-INF" );
290 $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w");
291 fwrite($outp, "Manifest-Version: 1.0\n");
292 fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n");
293 fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n");
kitlo9c7c62a2008-10-05 16:05:19 +0000294 fwrite($outp, "Bundle-Version: $train_version_timestamp\n");
295 fwrite($outp, "Bundle-Vendor: Eclipse.org\n");
kitlo58d8a5a2008-09-24 20:08:44 +0000296 fwrite($outp, "Fragment-Host: $parent_plugin_id\n");
297 fclose($outp);
droy0b08d292008-05-28 15:18:11 +0000298 /*
299 * Jar up this directory as the fragment plug-in jar
300 */
kitlo58d8a5a2008-09-24 20:08:44 +0000301 system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename .");
302 echo "${leader}${leader}Completed plug-in fragment $plugin_name\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000303
kitlo9c7c62a2008-10-05 16:05:19 +0000304 $projects[$project_id][] = $fragment_id;
305 $project_versions[$project_id] = $properties_file['version'];
droy0b08d292008-05-28 15:18:11 +0000306 }
kitlo9c7c62a2008-10-05 16:05:19 +0000307 foreach ($projects as $project_id => $fragment_ids) {
308 /*
309 * Sort fragment names
310 */
311 asort($fragment_ids);
312 /*
313 * Create ${babel_language_packs_dir}tmp
314 */
315 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features");
316 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/plugins");
317 /*
318 * Clean and create the temporary directory
319 */
320 if (file_exists($tmp_dir)) {
321 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
322 } else {
323 exec("mkdir $tmp_dir");
324 }
325 /*
326 * Create the feature.xml
327 *
328 * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented
329 *
330 * <url>
331 * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
332 * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
333 * </url>
334 */
kitlo5c9da712008-10-27 12:45:40 +0000335 $feature_id = "org.eclipse.babel.nls_${project_id}_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000336 $feature_filename = "${feature_id}_$train_version_timestamp.jar";
337
338 $project_version = $project_versions[$project_id];
339 $sql = "SELECT pct_complete
340 FROM project_progress
341 WHERE project_id = \"$project_id\"
342 AND version = \"$project_version\"
343 AND language_id = $language_id";
344 $project_pct_complete_result = mysql_query($sql);
345 $project_pct_complete = mysql_result($project_pct_complete_result, 0);
346 if (strcmp($language_iso, "en_AA") == 0) {
347 $project_pct_complete = 100;
348 }
349
350 $outp = fopen("$tmp_dir/feature.xml", "w");
351 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" .
352 "\n<feature" .
353 "\n\tid=\"$feature_id\"" .
354 "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" .
355 "\n\timage=\"eclipse_update_120.jpg\"" .
356 "\n\tprovider-name=\"%providerName\"" .
357 "\n\tversion=\"$train_version_timestamp\">" .
358 "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" .
359 "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" .
360 "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" );
361 foreach ($fragment_ids as $fragment_id) {
362 $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar";
363 $size = filesize($jar_name);
364 fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " .
365 "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />");
366 /*
367 * Copy the plugin to ${babel_language_packs_dir}tmp
368 */
369 exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir}tmp/eclipse/plugins");
370 }
371 fwrite($outp, "\n</feature>");
372 fclose($outp);
373 /*
374 * Copy in the various legal files
375 */
376 exec("cp ${source_files_dir}about.html $tmp_dir");
377 exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir");
378 exec("cp ${source_files_dir}epl-v10.html $tmp_dir");
379 exec("cp ${source_files_dir}feature.properties $tmp_dir");
380 exec("cp ${source_files_dir}license.html $tmp_dir");
381 /*
382 * Copy in the Babel Pseudo Translations Index file
383 */
384 if (strcmp($language_iso, "en_AA") == 0) {
385 $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w");
386 fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" .
387 "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" .
388 "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" .
389 "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" .
390 "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>");
391 foreach ($pseudo_translations_indexes[$project_id] as $index) {
392 fwrite($pseudo_translations_index_file, $index);
393 }
droy03d5c462008-11-10 21:07:01 +0000394 fwrite($pseudo_translations_index_file, "\n\t</ul>\n</div></div></body>\n</html>");
kitlo9c7c62a2008-10-05 16:05:19 +0000395 fclose($pseudo_translations_index_file);
396 exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir");
397 exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html");
398 }
399 /*
400 * Copy the feature to ${babel_language_packs_dir}tmp before jar'ing up
401 */
kitloc42941d2008-11-20 15:33:00 +0000402 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp");
403 exec("cd $tmp_dir; cp * ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp");
kitlo9c7c62a2008-10-05 16:05:19 +0000404 /*
405 * Zip up language pack
406 */
407 $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip";
408 exec("cd ${babel_language_packs_dir}tmp; zip -r $babel_language_packs_dir$language_pack_name eclipse");
409 /*
410 * Clean up ${babel_language_packs_dir}tmp
411 */
412 exec("rm -rf ${babel_language_packs_dir}tmp");
413 /*
414 * Add project language pack link to language pack links file
415 */
kitlo18ebeee2008-11-20 15:45:34 +0000416 fwrite($language_pack_links_file, "\n\t<li><a href=\"${language_pack_leader}${language_pack_name}\">$language_pack_name ($project_pct_complete%)</a></li>");
kitlo9c7c62a2008-10-05 16:05:19 +0000417 /*
418 * Jar up this directory as the feature jar
419 */
420 system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename .");
421 /*
422 * Register this feature with the site.xml
423 */
kitloc42941d2008-11-20 15:33:00 +0000424 $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$train_version_timestamp\">";
kitlo9c7c62a2008-10-05 16:05:19 +0000425 $site_xml .= "\n\t\t<category name=\"Babel Language Packs in $language_name\"/>";
426 $site_xml .= "\n\t</feature>";
427 echo "${leader}Completed language pack for $language_name ($language_iso)\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000428 }
kitlo9c7c62a2008-10-05 16:05:19 +0000429 fwrite($language_pack_links_file, "\n\t</ul>");
gobrien1a8e02f2008-01-30 01:46:26 +0000430 }
gobrien1a8e02f2008-01-30 01:46:26 +0000431 /*
droy0b08d292008-05-28 15:18:11 +0000432 * <site mirrorsURL=... implemented in the weekly build process by sed'ing <site>
gobrien1a8e02f2008-01-30 01:46:26 +0000433 */
kitlo58d8a5a2008-09-24 20:08:44 +0000434 $outp = fopen("${output_dir_for_train}site.xml", "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000435 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
436 "\n<site>" .
437 "\n\t<description url=\"http://babel.eclipse.org/\">" .
438 "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." .
439 "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" .
440 "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." .
441 "\n\t</description>");
kitlo58d8a5a2008-09-24 20:08:44 +0000442 fwrite($outp, $site_xml);
kitlo9c7c62a2008-10-05 16:05:19 +0000443 fwrite($outp, "\n</site>");
kitlo58d8a5a2008-09-24 20:08:44 +0000444 fclose($outp);
kitlo9c7c62a2008-10-05 16:05:19 +0000445
446 fwrite($language_pack_links_file, "\n\t</ul>");
atoulmedbda4272009-01-20 06:04:22 +0000447
448 // now generate the metadata and add the non-greedy tags
atoulme09ce4642009-01-21 07:46:06 +0000449
atoulme12882d52009-01-26 18:39:17 +0000450 system("sh " . dirname(__FILE__) . "/runMetadata.sh ".
atoulme09ce4642009-01-21 07:46:06 +0000451 METADATA_GENERATOR_LOCATION . " ${output_dir_for_train} ");
atoulmec86be152009-01-21 22:36:31 +0000452 system("xsltproc -o ${output_dir_for_train}content.xml ".
atoulmeb0f0e502009-01-21 17:27:25 +0000453 dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml");
atoulmec8efccd2009-02-13 08:51:59 +0000454 system("cd ${output_dir_for_train} ; jar -fc content.jar content.xml ; jar -fc artifacts.jar artifacts.xml ; rm site.xml");
gobrien1a8e02f2008-01-30 01:46:26 +0000455}
gobrien1a8e02f2008-01-30 01:46:26 +0000456echo "Completed generating update site\n";
457
kitlo9c7c62a2008-10-05 16:05:19 +0000458fwrite($language_pack_links_file, "\n</body>\n</html>");
459fclose($language_pack_links_file);
460
gobrien1a8e02f2008-01-30 01:46:26 +0000461/*
kitlo58d8a5a2008-09-24 20:08:44 +0000462 2. what happens if the translation feature includes plug-in fragments for
463 plug-ins that are not in the current image?
464 does it load correctly and ignore those fragments? if so, good
465 A: warnings appear in the run-time error log
466 does it fail to load? if so, then we need to generate different features, perhaps
467 one feature for each plug or else we need to know more about the project
468 distro structure to know which plug-ins to put in each feature
469 what happens if those plug-ins are later added - does it load the strings now?
470 A: probably not
471 3. need to handle different versions of each feature/plugin/platform; generate different
472 language packs for each
473 */
gobrien1a8e02f2008-01-30 01:46:26 +0000474
kitlo58d8a5a2008-09-24 20:08:44 +0000475$alloutput = fopen($output_dir."langpack_output_".date("m_d_Y"), "w");
476fwrite($alloutput,ob_get_contents());
kitlo399df202008-09-30 15:32:25 +0000477?>