blob: ab42707e508ff929c74b0371b1b3fd918ed619b1 [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
kitlo58d8a5a2008-09-24 20:08:44 +000019 *******************************************************************************/
gobrien1a8e02f2008-01-30 01:46:26 +000020
21/*
kitlo58d8a5a2008-09-24 20:08:44 +000022 * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs
gobrien1a8e02f2008-01-30 01:46:26 +000023 */
atoulme3fa5f5c2009-01-20 21:26:16 +000024define("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 +000025
kitlo9c7c62a2008-10-05 16:05:19 +000026ini_set("memory_limit", "64M");
atoulme12882d52009-01-26 18:39:17 +000027require(dirname(__FILE__) . "/../../html/common_functions.php");
28require(dirname(__FILE__) . "/../system/dbconnection.class.php");
kitlo399df202008-09-30 15:32:25 +000029$dbc = new DBConnection();
30$dbh = $dbc->connect();
droyb6e25c72008-07-18 13:01:13 +000031
kitlo58d8a5a2008-09-24 20:08:44 +000032$work_dir = "/home/babel-working/";
atoulme12882d52009-01-26 18:39:17 +000033
34global $context;
gobrienb854dcb2008-01-30 18:50:45 +000035
kitlo9c7c62a2008-10-05 16:05:19 +000036$work_context_dir = $work_dir . $context . "/";
37$tmp_dir = $work_context_dir . "tmp/";
38$babel_language_packs_dir = $work_context_dir . "babel_language_packs/";
39$output_dir = $work_context_dir . "output/";
kitlo58d8a5a2008-09-24 20:08:44 +000040$source_files_dir = "source_files_for_generate/";
gobrienb854dcb2008-01-30 18:50:45 +000041
droydfd5d622008-11-10 20:16:39 +000042# Language pack URL leader, to enable mirrors on download.eclipse.org
43$language_pack_leader = "";
44if($context == "live") {
45 $language_pack_leader = "http://www.eclipse.org/downloads/download.php?r=1&file=/technology/babel/babel_language_packs/";
46}
47
gobrien1a8e02f2008-01-30 01:46:26 +000048$leader = ". . ";
kitlo58d8a5a2008-09-24 20:08:44 +000049$timestamp = date("Ymdhis");
gobrien1a8e02f2008-01-30 01:46:26 +000050
droyd157aac2008-10-07 21:14:33 +000051$rm_command = "rm -rf $work_dir" . "*";
52exec($rm_command);
droy082976e2008-10-07 21:02:23 +000053exec("mkdir -p $output_dir");
54
kitlo9c7c62a2008-10-05 16:05:19 +000055/*
56 * Create language pack links file
57 */
58exec("mkdir -p $babel_language_packs_dir");
droydfd5d622008-11-10 20:16:39 +000059$language_pack_links_file = fopen("${babel_language_packs_dir}index.php", "w");
60fwrite($language_pack_links_file, "<?php\n\$pageTitle = \"Babel Language Packs\";\n");
droy4bef3dc2008-11-10 20:55:06 +000061fwrite($language_pack_links_file, "include \$_SERVER['DOCUMENT_ROOT'] . '/eclipse.org-common/themes/Phoenix/header.php';\n");
droydfd5d622008-11-10 20:16:39 +000062fwrite($language_pack_links_file, "?>\n");
droy03d5c462008-11-10 21:07:01 +000063fwrite($language_pack_links_file, "<div id='maincontent'><div id='midcolumn'>\n");
droydfd5d622008-11-10 20:16:39 +000064fwrite($language_pack_links_file, "\n\t<h1>Babel Language Packs</h1>" .
droyeb6d9b22008-11-24 18:42:28 +000065 "\n\t<h2>Build ID: $timestamp</h2>" .
66 "\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." .
67 "\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 +000068
kitlo58d8a5a2008-09-24 20:08:44 +000069echo "Generating update site\n";
droyeb6d9b22008-11-24 18:42:28 +000070$train_result = mysql_query("SELECT DISTINCT train_id FROM release_train_projects ORDER BY train_id DESC");
kitlo58d8a5a2008-09-24 20:08:44 +000071while (($train_row = mysql_fetch_assoc($train_result)) != null) {
72 $train_id = $train_row['train_id'];
73 $train_version = "3.4.0";
74 if (strcmp($train_id, "europa") == 0) {
75 $train_version = "3.3.0";
droy0b08d292008-05-28 15:18:11 +000076 }
kitlo9c7c62a2008-10-05 16:05:19 +000077 $train_version_timestamp = "$train_version.v$timestamp";
78 $site_xml = "";
kitlo58d8a5a2008-09-24 20:08:44 +000079
80 $output_dir_for_train = $output_dir . $train_row['train_id'] . "/";
81 exec("mkdir $output_dir_for_train");
82 exec("mkdir ${output_dir_for_train}features/");
83 exec("mkdir ${output_dir_for_train}plugins/");
84
kitlo9c7c62a2008-10-05 16:05:19 +000085 fwrite($language_pack_links_file, "\n\t<h3>Release Train: $train_id</h3>\n\t<ul>");
86
kitlo47df0c62009-01-22 15:16:18 +000087 $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 +000088 while (($language_row = mysql_fetch_assoc($language_result)) != null) {
droy0b08d292008-05-28 15:18:11 +000089 $language_name = $language_row['name'];
kitlo58d8a5a2008-09-24 20:08:44 +000090 $language_iso = $language_row['iso_code'];
kitlo58d8a5a2008-09-24 20:08:44 +000091 $language_id = $language_row['language_id'];
92 if (strcmp($language_iso, "en") == 0) {
93 $language_iso = "en_AA";
94 $language_name = "Pseudo Translations";
95 }
kitlo9c7c62a2008-10-05 16:05:19 +000096
97 $site_xml .= "\n\t<category-def name=\"Babel Language Packs in $language_name\" label=\"Babel Language Packs in $language_name\">";
98 $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>";
99 $site_xml .= "\n\t</category-def>";
100
101 fwrite($language_pack_links_file, "\n\t<h4>Language: $language_name</h4>\n\t<ul>");
102
kitlo58d8a5a2008-09-24 20:08:44 +0000103 echo "${leader}Generating language pack for $train_id - $language_name ($language_iso) (language_id=" . $language_id . ")\n";
104
gobrien1a8e02f2008-01-30 01:46:26 +0000105 /*
droy0b08d292008-05-28 15:18:11 +0000106 * Determine which plug-ins need to be in this language pack.
gobrien1a8e02f2008-01-30 01:46:26 +0000107 */
kitlo58d8a5a2008-09-24 20:08:44 +0000108 if (strcmp($language_iso, "en_AA") == 0) {
109 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
110 FROM files AS f
111 INNER JOIN strings AS s ON f.file_id = s.file_id
112 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
113 WHERE f.is_active
114 AND v.train_id = '" . $train_row['train_id'] . "'");
kitlo58d8a5a2008-09-24 20:08:44 +0000115 } else {
116 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
117 FROM files AS f
118 INNER JOIN strings AS s ON f.file_id = s.file_id
119 INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active)
120 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
121 WHERE t.language_id = " . $language_id . "
122 AND f.is_active
123 AND v.train_id = '" . $train_row['train_id'] . "'");
124 }
125
droy0b08d292008-05-28 15:18:11 +0000126 $plugins = array();
kitlo9c7c62a2008-10-05 16:05:19 +0000127 $projects = array();
128 $project_versions = array();
129 $pseudo_translations_indexes = array();
kitlo58d8a5a2008-09-24 20:08:44 +0000130 while (($file_row = mysql_fetch_assoc($file_result)) != null) {
131 # save original filename
132 $file_row['origname'] = $file_row['name'];
133
droy02c430a2008-06-02 19:42:08 +0000134 # strip useless CVS structure before the plugin name (bug 221675 c14):
135 $pattern = '/^([a-zA-Z0-9\/_-])+\/([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)(.*)\.properties$/i';
136 $replace = '${2}.${3}${4}.properties';
137 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000138
droy02c430a2008-06-02 19:42:08 +0000139 # strip source folder (bug 221675) (org.eclipse.plugin/source_folder/org/eclipse/plugin)
140 $pattern = '/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9\._-]+)(.*)\/(\1)([\.\/])(\2)([\.\/])(.*)\.properties$/i';
141 $replace = '${1}.${2}.${3}/${5}${6}${7}${8}${9}.properties';
droy0b08d292008-05-28 15:18:11 +0000142 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000143
144 if (preg_match("/^([a-zA-Z0-9\.]+)\/(.*)$/", $file_row['name'], $matches)) {
droy0b08d292008-05-28 15:18:11 +0000145 $file_row['subname'] = $matches[2];
146 $plugins[$matches[1]][] = $file_row;
147 } else {
148 echo " WARNING: no plug-in name found in file " . $file_row['file_id'] . " \"" . $file_row['name'] . "\"\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000149 }
droy0b08d292008-05-28 15:18:11 +0000150 }
kitlo58d8a5a2008-09-24 20:08:44 +0000151
droy0b08d292008-05-28 15:18:11 +0000152 /*
153 * Generate one plug-in fragment for each plug-in
154 */
kitlo58d8a5a2008-09-24 20:08:44 +0000155 foreach ($plugins as $plugin_name => $plugin_row) {
156 echo "${leader}${leader}Generating plug-in fragment $plugin_name\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000157 /*
droy0b08d292008-05-28 15:18:11 +0000158 * Clean and create the temporary directory
gobrien1a8e02f2008-01-30 01:46:26 +0000159 */
kitlo58d8a5a2008-09-24 20:08:44 +0000160 if (file_exists($tmp_dir)) {
161 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000162 } else {
kitlo58d8a5a2008-09-24 20:08:44 +0000163 exec("mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000164 }
gobrien1a8e02f2008-01-30 01:46:26 +0000165 /*
droy0b08d292008-05-28 15:18:11 +0000166 * Generate each *.properties file
gobrien1a8e02f2008-01-30 01:46:26 +0000167 */
droy0b08d292008-05-28 15:18:11 +0000168 foreach ($plugin_row as $properties_file) {
169 /*
170 * Convert the filename to *_lang.properties, e.g., foo_fr.properties
171 */
172 $filename = $properties_file['subname'];
kitlo58d8a5a2008-09-24 20:08:44 +0000173 if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) {
droy0b08d292008-05-28 15:18:11 +0000174 $filename = $matches[1] . '_' . $language_iso . '.properties';
gobrien1a8e02f2008-01-30 01:46:26 +0000175 }
kitlo58d8a5a2008-09-24 20:08:44 +0000176 echo "${leader}${leader}${leader}Generating properties file $filename (file_id=" . $properties_file['file_id'] . ")\n";
droy0b08d292008-05-28 15:18:11 +0000177 /*
178 * Create any needed sub-directories
179 */
kitlo58d8a5a2008-09-24 20:08:44 +0000180 $fullpath = $tmp_dir . $filename;
181 preg_match("/^((.*)\/)?(.+?)$/", $fullpath, $matches);
182 exec("mkdir -p \"" . $matches[1] . "\"");
droy0b08d292008-05-28 15:18:11 +0000183 /*
184 * Start writing to the file
185 */
kitlo58d8a5a2008-09-24 20:08:44 +0000186 $outp = fopen($fullpath, "w");
kitloc42941d2008-11-20 15:33:00 +0000187 fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/");
kitlo58d8a5a2008-09-24 20:08:44 +0000188 if (strcmp($language_iso, "en_AA") == 0) {
189 $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] .
190 " AND is_active AND non_translatable = 0";
191 $strings_result = mysql_query($sql);
192 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo9c7c62a2008-10-05 16:05:19 +0000193 fwrite($outp, "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] .
194 ":" . $strings_row['value']);
kitlo58d8a5a2008-09-24 20:08:44 +0000195
196 $value = htmlspecialchars($strings_row['value']);
197 if (strlen($value) > 100) {
198 $value = substr($value, 0, 100) . " ...";
199 }
kitlo9c7c62a2008-10-05 16:05:19 +0000200 $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" .
201 $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" .
202 $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" .
203 $properties_file['project_id'] . $strings_row['string_id'] . "</a>&nbsp;" . $value . "</li>";
kitlo58d8a5a2008-09-24 20:08:44 +0000204 }
205 } else {
206 $sql = "SELECT
207 strings.name AS 'key',
208 strings.value AS orig,
209 translations.value AS trans
droy0b08d292008-05-28 15:18:11 +0000210 FROM strings, translations
211 WHERE strings.string_id = translations.string_id
droy0b08d292008-05-28 15:18:11 +0000212 AND strings.file_id = " . $properties_file['file_id'] . "
kitlo1173dbd2008-10-21 15:58:36 +0000213 AND strings.is_active
214 AND strings.non_translatable = 0
215 AND translations.language_id = " . $language_id . "
kitlo58d8a5a2008-09-24 20:08:44 +0000216 AND translations.is_active";
217 $strings_result = mysql_query($sql);
218 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo7f522672008-10-21 14:15:54 +0000219 fwrite($outp, "\n" . $strings_row['key'] . "=");
kitlo9c7c62a2008-10-05 16:05:19 +0000220 # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "=";
kitlo58d8a5a2008-09-24 20:08:44 +0000221 if ($strings_row['trans']) {
222 # json_encode returns the string with quotes fore and aft. Need to strip them.
223 # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
224 # $tr_string = str_replace('\\\\', '\\', $tr_string);
225 $tr_string = toescapedunicode($strings_row['trans']);
226 fwrite($outp, $tr_string);
227 # echo $strings_row['trans'];
228 } else {
229 fwrite($outp, $strings_row['orig']);
230 }
droy0b08d292008-05-28 15:18:11 +0000231 }
droy0b08d292008-05-28 15:18:11 +0000232 }
233 /*
234 * Finish the properties file
235 */
kitlo58d8a5a2008-09-24 20:08:44 +0000236 fclose($outp);
237 echo "${leader}${leader}${leader}Completed properties file $filename\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000238 }
239 /*
droy0b08d292008-05-28 15:18:11 +0000240 * Copy in the various legal files
gobrien1a8e02f2008-01-30 01:46:26 +0000241 */
kitlo9c7c62a2008-10-05 16:05:19 +0000242 exec("cp ${source_files_dir}about.html $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000243 /*
244 * Generate the META-INF/MANIFEST.MF file
245 */
246 $parent_plugin_id = $plugin_name;
kitlo9c7c62a2008-10-05 16:05:19 +0000247 $project_id = $properties_file['project_id'];
kitlo5c9da712008-10-27 12:45:40 +0000248 $fragment_id = "$parent_plugin_id.nl_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000249 $fragment_filename = "${fragment_id}_$train_version_timestamp.jar";
kitlo58d8a5a2008-09-24 20:08:44 +0000250
droy0b08d292008-05-28 15:18:11 +0000251 $plugins[$plugin_name]['id'] = $fragment_id;
kitlo9c7c62a2008-10-05 16:05:19 +0000252 $plugins[$plugin_name]['version'] = $train_version_timestamp;
kitlo58d8a5a2008-09-24 20:08:44 +0000253
254 exec("mkdir $tmp_dir/META-INF" );
255 $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w");
256 fwrite($outp, "Manifest-Version: 1.0\n");
257 fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n");
258 fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n");
kitlo9c7c62a2008-10-05 16:05:19 +0000259 fwrite($outp, "Bundle-Version: $train_version_timestamp\n");
260 fwrite($outp, "Bundle-Vendor: Eclipse.org\n");
kitlo58d8a5a2008-09-24 20:08:44 +0000261 fwrite($outp, "Fragment-Host: $parent_plugin_id\n");
262 fclose($outp);
droy0b08d292008-05-28 15:18:11 +0000263 /*
264 * Jar up this directory as the fragment plug-in jar
265 */
kitlo58d8a5a2008-09-24 20:08:44 +0000266 system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename .");
267 echo "${leader}${leader}Completed plug-in fragment $plugin_name\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000268
kitlo9c7c62a2008-10-05 16:05:19 +0000269 $projects[$project_id][] = $fragment_id;
270 $project_versions[$project_id] = $properties_file['version'];
droy0b08d292008-05-28 15:18:11 +0000271 }
kitlo9c7c62a2008-10-05 16:05:19 +0000272 foreach ($projects as $project_id => $fragment_ids) {
273 /*
274 * Sort fragment names
275 */
276 asort($fragment_ids);
277 /*
278 * Create ${babel_language_packs_dir}tmp
279 */
280 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features");
281 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/plugins");
282 /*
283 * Clean and create the temporary directory
284 */
285 if (file_exists($tmp_dir)) {
286 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
287 } else {
288 exec("mkdir $tmp_dir");
289 }
290 /*
291 * Create the feature.xml
292 *
293 * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented
294 *
295 * <url>
296 * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
297 * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
298 * </url>
299 */
kitlo5c9da712008-10-27 12:45:40 +0000300 $feature_id = "org.eclipse.babel.nls_${project_id}_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000301 $feature_filename = "${feature_id}_$train_version_timestamp.jar";
302
303 $project_version = $project_versions[$project_id];
304 $sql = "SELECT pct_complete
305 FROM project_progress
306 WHERE project_id = \"$project_id\"
307 AND version = \"$project_version\"
308 AND language_id = $language_id";
309 $project_pct_complete_result = mysql_query($sql);
310 $project_pct_complete = mysql_result($project_pct_complete_result, 0);
311 if (strcmp($language_iso, "en_AA") == 0) {
312 $project_pct_complete = 100;
313 }
314
315 $outp = fopen("$tmp_dir/feature.xml", "w");
316 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" .
317 "\n<feature" .
318 "\n\tid=\"$feature_id\"" .
319 "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" .
320 "\n\timage=\"eclipse_update_120.jpg\"" .
321 "\n\tprovider-name=\"%providerName\"" .
322 "\n\tversion=\"$train_version_timestamp\">" .
323 "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" .
324 "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" .
325 "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" );
326 foreach ($fragment_ids as $fragment_id) {
327 $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar";
328 $size = filesize($jar_name);
329 fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " .
330 "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />");
331 /*
332 * Copy the plugin to ${babel_language_packs_dir}tmp
333 */
334 exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir}tmp/eclipse/plugins");
335 }
336 fwrite($outp, "\n</feature>");
337 fclose($outp);
338 /*
339 * Copy in the various legal files
340 */
341 exec("cp ${source_files_dir}about.html $tmp_dir");
342 exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir");
343 exec("cp ${source_files_dir}epl-v10.html $tmp_dir");
344 exec("cp ${source_files_dir}feature.properties $tmp_dir");
345 exec("cp ${source_files_dir}license.html $tmp_dir");
346 /*
347 * Copy in the Babel Pseudo Translations Index file
348 */
349 if (strcmp($language_iso, "en_AA") == 0) {
350 $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w");
351 fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" .
352 "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" .
353 "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" .
354 "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" .
355 "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>");
356 foreach ($pseudo_translations_indexes[$project_id] as $index) {
357 fwrite($pseudo_translations_index_file, $index);
358 }
droy03d5c462008-11-10 21:07:01 +0000359 fwrite($pseudo_translations_index_file, "\n\t</ul>\n</div></div></body>\n</html>");
kitlo9c7c62a2008-10-05 16:05:19 +0000360 fclose($pseudo_translations_index_file);
361 exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir");
362 exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html");
363 }
364 /*
365 * Copy the feature to ${babel_language_packs_dir}tmp before jar'ing up
366 */
kitloc42941d2008-11-20 15:33:00 +0000367 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp");
368 exec("cd $tmp_dir; cp * ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp");
kitlo9c7c62a2008-10-05 16:05:19 +0000369 /*
370 * Zip up language pack
371 */
372 $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip";
373 exec("cd ${babel_language_packs_dir}tmp; zip -r $babel_language_packs_dir$language_pack_name eclipse");
374 /*
375 * Clean up ${babel_language_packs_dir}tmp
376 */
377 exec("rm -rf ${babel_language_packs_dir}tmp");
378 /*
379 * Add project language pack link to language pack links file
380 */
kitlo18ebeee2008-11-20 15:45:34 +0000381 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 +0000382 /*
383 * Jar up this directory as the feature jar
384 */
385 system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename .");
386 /*
387 * Register this feature with the site.xml
388 */
kitloc42941d2008-11-20 15:33:00 +0000389 $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$train_version_timestamp\">";
kitlo9c7c62a2008-10-05 16:05:19 +0000390 $site_xml .= "\n\t\t<category name=\"Babel Language Packs in $language_name\"/>";
391 $site_xml .= "\n\t</feature>";
392 echo "${leader}Completed language pack for $language_name ($language_iso)\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000393 }
kitlo9c7c62a2008-10-05 16:05:19 +0000394 fwrite($language_pack_links_file, "\n\t</ul>");
gobrien1a8e02f2008-01-30 01:46:26 +0000395 }
gobrien1a8e02f2008-01-30 01:46:26 +0000396 /*
droy0b08d292008-05-28 15:18:11 +0000397 * <site mirrorsURL=... implemented in the weekly build process by sed'ing <site>
gobrien1a8e02f2008-01-30 01:46:26 +0000398 */
kitlo58d8a5a2008-09-24 20:08:44 +0000399 $outp = fopen("${output_dir_for_train}site.xml", "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000400 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
401 "\n<site>" .
402 "\n\t<description url=\"http://babel.eclipse.org/\">" .
403 "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." .
404 "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" .
405 "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." .
406 "\n\t</description>");
kitlo58d8a5a2008-09-24 20:08:44 +0000407 fwrite($outp, $site_xml);
kitlo9c7c62a2008-10-05 16:05:19 +0000408 fwrite($outp, "\n</site>");
kitlo58d8a5a2008-09-24 20:08:44 +0000409 fclose($outp);
kitlo9c7c62a2008-10-05 16:05:19 +0000410
411 fwrite($language_pack_links_file, "\n\t</ul>");
atoulmedbda4272009-01-20 06:04:22 +0000412
413 // now generate the metadata and add the non-greedy tags
atoulme09ce4642009-01-21 07:46:06 +0000414
atoulme12882d52009-01-26 18:39:17 +0000415 system("sh " . dirname(__FILE__) . "/runMetadata.sh ".
atoulme09ce4642009-01-21 07:46:06 +0000416 METADATA_GENERATOR_LOCATION . " ${output_dir_for_train} ");
atoulmec86be152009-01-21 22:36:31 +0000417 system("xsltproc -o ${output_dir_for_train}content.xml ".
atoulmeb0f0e502009-01-21 17:27:25 +0000418 dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml");
atoulme99b653c2009-01-23 09:36:23 +0000419 system("cd ${output_dir_for_train} ; jar -fc content.jar artifacts.xml content.xml");
gobrien1a8e02f2008-01-30 01:46:26 +0000420}
gobrien1a8e02f2008-01-30 01:46:26 +0000421echo "Completed generating update site\n";
422
kitlo9c7c62a2008-10-05 16:05:19 +0000423fwrite($language_pack_links_file, "\n</body>\n</html>");
424fclose($language_pack_links_file);
425
gobrien1a8e02f2008-01-30 01:46:26 +0000426/*
kitlo58d8a5a2008-09-24 20:08:44 +0000427 2. what happens if the translation feature includes plug-in fragments for
428 plug-ins that are not in the current image?
429 does it load correctly and ignore those fragments? if so, good
430 A: warnings appear in the run-time error log
431 does it fail to load? if so, then we need to generate different features, perhaps
432 one feature for each plug or else we need to know more about the project
433 distro structure to know which plug-ins to put in each feature
434 what happens if those plug-ins are later added - does it load the strings now?
435 A: probably not
436 3. need to handle different versions of each feature/plugin/platform; generate different
437 language packs for each
438 */
gobrien1a8e02f2008-01-30 01:46:26 +0000439
kitlo58d8a5a2008-09-24 20:08:44 +0000440$alloutput = fopen($output_dir."langpack_output_".date("m_d_Y"), "w");
441fwrite($alloutput,ob_get_contents());
kitlo399df202008-09-30 15:32:25 +0000442?>