blob: 708d36ca285e67162aab08d11a36dc928082e1c4 [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
kitlo58d8a5a2008-09-24 20:08:44 +000017 *******************************************************************************/
gobrien1a8e02f2008-01-30 01:46:26 +000018
19/*
kitlo58d8a5a2008-09-24 20:08:44 +000020 * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs
gobrien1a8e02f2008-01-30 01:46:26 +000021 */
gobrienb854dcb2008-01-30 18:50:45 +000022
droyb6e25c72008-07-18 13:01:13 +000023ob_start();
kitlo9c7c62a2008-10-05 16:05:19 +000024ini_set("memory_limit", "64M");
kitlo58d8a5a2008-09-24 20:08:44 +000025define("BABEL_BASE_DIR", "../../");
kitlo9c7c62a2008-10-05 16:05:19 +000026require(BABEL_BASE_DIR . "html/common_functions.php");
27require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php");
kitlo399df202008-09-30 15:32:25 +000028$dbc = new DBConnection();
29$dbh = $dbc->connect();
droyb6e25c72008-07-18 13:01:13 +000030
kitlo58d8a5a2008-09-24 20:08:44 +000031$work_dir = "/home/babel-working/";
kitlo9c7c62a2008-10-05 16:05:19 +000032if (!($ini = @parse_ini_file(BABEL_BASE_DIR . "classes/base.conf"))) {
gobrienb854dcb2008-01-30 18:50:45 +000033 errorLog("Failed to find/read database conf file - aborting.");
34 exitTo("error.php?errNo=101300","error: 101300 - database conf can not be found");
35}
gobrienb854dcb2008-01-30 18:50:45 +000036$context = $ini['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/";
kitlo58d8a5a2008-09-24 20:08:44 +000042$source_files_dir = "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>" .
kitlo9c7c62a2008-10-05 16:05:19 +000067 "\n\t<h2>Build ID: $timestamp</h2>");
droy0b08d292008-05-28 15:18:11 +000068
kitlo58d8a5a2008-09-24 20:08:44 +000069echo "Generating update site\n";
kitlo9c7c62a2008-10-05 16:05:19 +000070$train_result = mysql_query("SELECT DISTINCT train_id FROM release_train_projects");
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
87 $language_result = mysql_query("SELECT * FROM languages WHERE languages.is_active");
88 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'];
91 $language_locale = $language_row['locale'];
92 $language_id = $language_row['language_id'];
93 if (strcmp($language_iso, "en") == 0) {
94 $language_iso = "en_AA";
95 $language_name = "Pseudo Translations";
96 }
97 if ($language_locale != null) {
droy0b08d292008-05-28 15:18:11 +000098 $language_name = $language_locale . " " . $language_name;
gobrien1a8e02f2008-01-30 01:46:26 +000099 }
kitlo9c7c62a2008-10-05 16:05:19 +0000100
101 $site_xml .= "\n\t<category-def name=\"Babel Language Packs in $language_name\" label=\"Babel Language Packs in $language_name\">";
102 $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>";
103 $site_xml .= "\n\t</category-def>";
104
105 fwrite($language_pack_links_file, "\n\t<h4>Language: $language_name</h4>\n\t<ul>");
106
kitlo58d8a5a2008-09-24 20:08:44 +0000107 echo "${leader}Generating language pack for $train_id - $language_name ($language_iso) (language_id=" . $language_id . ")\n";
108
gobrien1a8e02f2008-01-30 01:46:26 +0000109 /*
droy0b08d292008-05-28 15:18:11 +0000110 * Determine which plug-ins need to be in this language pack.
gobrien1a8e02f2008-01-30 01:46:26 +0000111 */
kitlo58d8a5a2008-09-24 20:08:44 +0000112 if (strcmp($language_iso, "en_AA") == 0) {
113 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
114 FROM files AS f
115 INNER JOIN strings AS s ON f.file_id = s.file_id
116 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
117 WHERE f.is_active
118 AND v.train_id = '" . $train_row['train_id'] . "'");
kitlo58d8a5a2008-09-24 20:08:44 +0000119 } else {
120 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
121 FROM files AS f
122 INNER JOIN strings AS s ON f.file_id = s.file_id
123 INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active)
124 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
125 WHERE t.language_id = " . $language_id . "
126 AND f.is_active
127 AND v.train_id = '" . $train_row['train_id'] . "'");
128 }
129
droy0b08d292008-05-28 15:18:11 +0000130 $plugins = array();
kitlo9c7c62a2008-10-05 16:05:19 +0000131 $projects = array();
132 $project_versions = array();
133 $pseudo_translations_indexes = array();
kitlo58d8a5a2008-09-24 20:08:44 +0000134 while (($file_row = mysql_fetch_assoc($file_result)) != null) {
135 # save original filename
136 $file_row['origname'] = $file_row['name'];
137
droy02c430a2008-06-02 19:42:08 +0000138 # strip useless CVS structure before the plugin name (bug 221675 c14):
139 $pattern = '/^([a-zA-Z0-9\/_-])+\/([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)(.*)\.properties$/i';
140 $replace = '${2}.${3}${4}.properties';
141 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000142
droy02c430a2008-06-02 19:42:08 +0000143 # strip source folder (bug 221675) (org.eclipse.plugin/source_folder/org/eclipse/plugin)
144 $pattern = '/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9\._-]+)(.*)\/(\1)([\.\/])(\2)([\.\/])(.*)\.properties$/i';
145 $replace = '${1}.${2}.${3}/${5}${6}${7}${8}${9}.properties';
droy0b08d292008-05-28 15:18:11 +0000146 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000147
148 if (preg_match("/^([a-zA-Z0-9\.]+)\/(.*)$/", $file_row['name'], $matches)) {
droy0b08d292008-05-28 15:18:11 +0000149 $file_row['subname'] = $matches[2];
150 $plugins[$matches[1]][] = $file_row;
151 } else {
152 echo " WARNING: no plug-in name found in file " . $file_row['file_id'] . " \"" . $file_row['name'] . "\"\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000153 }
droy0b08d292008-05-28 15:18:11 +0000154 }
kitlo58d8a5a2008-09-24 20:08:44 +0000155
droy0b08d292008-05-28 15:18:11 +0000156 /*
157 * Generate one plug-in fragment for each plug-in
158 */
kitlo58d8a5a2008-09-24 20:08:44 +0000159 foreach ($plugins as $plugin_name => $plugin_row) {
160 echo "${leader}${leader}Generating plug-in fragment $plugin_name\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000161 /*
droy0b08d292008-05-28 15:18:11 +0000162 * Clean and create the temporary directory
gobrien1a8e02f2008-01-30 01:46:26 +0000163 */
kitlo58d8a5a2008-09-24 20:08:44 +0000164 if (file_exists($tmp_dir)) {
165 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000166 } else {
kitlo58d8a5a2008-09-24 20:08:44 +0000167 exec("mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000168 }
gobrien1a8e02f2008-01-30 01:46:26 +0000169 /*
droy0b08d292008-05-28 15:18:11 +0000170 * Generate each *.properties file
gobrien1a8e02f2008-01-30 01:46:26 +0000171 */
droy0b08d292008-05-28 15:18:11 +0000172 foreach ($plugin_row as $properties_file) {
173 /*
174 * Convert the filename to *_lang.properties, e.g., foo_fr.properties
175 */
176 $filename = $properties_file['subname'];
kitlo58d8a5a2008-09-24 20:08:44 +0000177 if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) {
droy0b08d292008-05-28 15:18:11 +0000178 $filename = $matches[1] . '_' . $language_iso . '.properties';
gobrien1a8e02f2008-01-30 01:46:26 +0000179 }
kitlo58d8a5a2008-09-24 20:08:44 +0000180 echo "${leader}${leader}${leader}Generating properties file $filename (file_id=" . $properties_file['file_id'] . ")\n";
droy0b08d292008-05-28 15:18:11 +0000181 /*
182 * Create any needed sub-directories
183 */
kitlo58d8a5a2008-09-24 20:08:44 +0000184 $fullpath = $tmp_dir . $filename;
185 preg_match("/^((.*)\/)?(.+?)$/", $fullpath, $matches);
186 exec("mkdir -p \"" . $matches[1] . "\"");
droy0b08d292008-05-28 15:18:11 +0000187 /*
188 * Start writing to the file
189 */
kitlo58d8a5a2008-09-24 20:08:44 +0000190 $outp = fopen($fullpath, "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000191 fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/");
kitlo58d8a5a2008-09-24 20:08:44 +0000192 if (strcmp($language_iso, "en_AA") == 0) {
193 $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] .
194 " AND is_active AND non_translatable = 0";
195 $strings_result = mysql_query($sql);
196 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo9c7c62a2008-10-05 16:05:19 +0000197 fwrite($outp, "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] .
198 ":" . $strings_row['value']);
kitlo58d8a5a2008-09-24 20:08:44 +0000199
200 $value = htmlspecialchars($strings_row['value']);
201 if (strlen($value) > 100) {
202 $value = substr($value, 0, 100) . " ...";
203 }
kitlo9c7c62a2008-10-05 16:05:19 +0000204 $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" .
205 $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" .
206 $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" .
207 $properties_file['project_id'] . $strings_row['string_id'] . "</a>&nbsp;" . $value . "</li>";
kitlo58d8a5a2008-09-24 20:08:44 +0000208 }
209 } else {
210 $sql = "SELECT
211 strings.name AS 'key',
212 strings.value AS orig,
213 translations.value AS trans
droy0b08d292008-05-28 15:18:11 +0000214 FROM strings, translations
215 WHERE strings.string_id = translations.string_id
droy0b08d292008-05-28 15:18:11 +0000216 AND strings.file_id = " . $properties_file['file_id'] . "
kitlo1173dbd2008-10-21 15:58:36 +0000217 AND strings.is_active
218 AND strings.non_translatable = 0
219 AND translations.language_id = " . $language_id . "
kitlo58d8a5a2008-09-24 20:08:44 +0000220 AND translations.is_active";
221 $strings_result = mysql_query($sql);
222 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo7f522672008-10-21 14:15:54 +0000223 fwrite($outp, "\n" . $strings_row['key'] . "=");
kitlo9c7c62a2008-10-05 16:05:19 +0000224 # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "=";
kitlo58d8a5a2008-09-24 20:08:44 +0000225 if ($strings_row['trans']) {
226 # json_encode returns the string with quotes fore and aft. Need to strip them.
227 # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
228 # $tr_string = str_replace('\\\\', '\\', $tr_string);
229 $tr_string = toescapedunicode($strings_row['trans']);
230 fwrite($outp, $tr_string);
231 # echo $strings_row['trans'];
232 } else {
233 fwrite($outp, $strings_row['orig']);
234 }
235 fwrite($outp, "\n");
droy0b08d292008-05-28 15:18:11 +0000236 }
droy0b08d292008-05-28 15:18:11 +0000237 }
238 /*
239 * Finish the properties file
240 */
kitlo58d8a5a2008-09-24 20:08:44 +0000241 fclose($outp);
242 echo "${leader}${leader}${leader}Completed properties file $filename\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000243 }
244 /*
droy0b08d292008-05-28 15:18:11 +0000245 * Copy in the various legal files
gobrien1a8e02f2008-01-30 01:46:26 +0000246 */
kitlo9c7c62a2008-10-05 16:05:19 +0000247 exec("cp ${source_files_dir}about.html $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000248 /*
249 * Generate the META-INF/MANIFEST.MF file
250 */
251 $parent_plugin_id = $plugin_name;
kitlo9c7c62a2008-10-05 16:05:19 +0000252 $project_id = $properties_file['project_id'];
kitlo5c9da712008-10-27 12:45:40 +0000253 $fragment_id = "$parent_plugin_id.nl_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000254 $fragment_filename = "${fragment_id}_$train_version_timestamp.jar";
kitlo58d8a5a2008-09-24 20:08:44 +0000255
droy0b08d292008-05-28 15:18:11 +0000256 $plugins[$plugin_name]['id'] = $fragment_id;
kitlo9c7c62a2008-10-05 16:05:19 +0000257 $plugins[$plugin_name]['version'] = $train_version_timestamp;
kitlo58d8a5a2008-09-24 20:08:44 +0000258
259 exec("mkdir $tmp_dir/META-INF" );
260 $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w");
261 fwrite($outp, "Manifest-Version: 1.0\n");
262 fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n");
263 fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n");
kitlo9c7c62a2008-10-05 16:05:19 +0000264 fwrite($outp, "Bundle-Version: $train_version_timestamp\n");
265 fwrite($outp, "Bundle-Vendor: Eclipse.org\n");
kitlo58d8a5a2008-09-24 20:08:44 +0000266 fwrite($outp, "Fragment-Host: $parent_plugin_id\n");
267 fclose($outp);
droy0b08d292008-05-28 15:18:11 +0000268 /*
269 * Jar up this directory as the fragment plug-in jar
270 */
kitlo58d8a5a2008-09-24 20:08:44 +0000271 system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename .");
272 echo "${leader}${leader}Completed plug-in fragment $plugin_name\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000273
kitlo9c7c62a2008-10-05 16:05:19 +0000274 $projects[$project_id][] = $fragment_id;
275 $project_versions[$project_id] = $properties_file['version'];
droy0b08d292008-05-28 15:18:11 +0000276 }
kitlo9c7c62a2008-10-05 16:05:19 +0000277 foreach ($projects as $project_id => $fragment_ids) {
278 /*
279 * Sort fragment names
280 */
281 asort($fragment_ids);
282 /*
283 * Create ${babel_language_packs_dir}tmp
284 */
285 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features");
286 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/plugins");
287 /*
288 * Clean and create the temporary directory
289 */
290 if (file_exists($tmp_dir)) {
291 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
292 } else {
293 exec("mkdir $tmp_dir");
294 }
295 /*
296 * Create the feature.xml
297 *
298 * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented
299 *
300 * <url>
301 * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
302 * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
303 * </url>
304 */
kitlo5c9da712008-10-27 12:45:40 +0000305 $feature_id = "org.eclipse.babel.nls_${project_id}_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000306 $feature_version = "$train_version.v$timestamp";
307 $feature_filename = "${feature_id}_$train_version_timestamp.jar";
308
309 $project_version = $project_versions[$project_id];
310 $sql = "SELECT pct_complete
311 FROM project_progress
312 WHERE project_id = \"$project_id\"
313 AND version = \"$project_version\"
314 AND language_id = $language_id";
315 $project_pct_complete_result = mysql_query($sql);
316 $project_pct_complete = mysql_result($project_pct_complete_result, 0);
317 if (strcmp($language_iso, "en_AA") == 0) {
318 $project_pct_complete = 100;
319 }
320
321 $outp = fopen("$tmp_dir/feature.xml", "w");
322 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" .
323 "\n<feature" .
324 "\n\tid=\"$feature_id\"" .
325 "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" .
326 "\n\timage=\"eclipse_update_120.jpg\"" .
327 "\n\tprovider-name=\"%providerName\"" .
328 "\n\tversion=\"$train_version_timestamp\">" .
329 "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" .
330 "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" .
331 "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" );
332 foreach ($fragment_ids as $fragment_id) {
333 $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar";
334 $size = filesize($jar_name);
335 fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " .
336 "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />");
337 /*
338 * Copy the plugin to ${babel_language_packs_dir}tmp
339 */
340 exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir}tmp/eclipse/plugins");
341 }
342 fwrite($outp, "\n</feature>");
343 fclose($outp);
344 /*
345 * Copy in the various legal files
346 */
347 exec("cp ${source_files_dir}about.html $tmp_dir");
348 exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir");
349 exec("cp ${source_files_dir}epl-v10.html $tmp_dir");
350 exec("cp ${source_files_dir}feature.properties $tmp_dir");
351 exec("cp ${source_files_dir}license.html $tmp_dir");
352 /*
353 * Copy in the Babel Pseudo Translations Index file
354 */
355 if (strcmp($language_iso, "en_AA") == 0) {
356 $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w");
357 fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" .
358 "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" .
359 "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" .
360 "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" .
361 "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>");
362 foreach ($pseudo_translations_indexes[$project_id] as $index) {
363 fwrite($pseudo_translations_index_file, $index);
364 }
droy03d5c462008-11-10 21:07:01 +0000365 fwrite($pseudo_translations_index_file, "\n\t</ul>\n</div></div></body>\n</html>");
kitlo9c7c62a2008-10-05 16:05:19 +0000366 fclose($pseudo_translations_index_file);
367 exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir");
368 exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html");
369 }
370 /*
371 * Copy the feature to ${babel_language_packs_dir}tmp before jar'ing up
372 */
373 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features/${fragment_id}_$train_version_timestamp");
374 exec("cd $tmp_dir; cp * ${babel_language_packs_dir}tmp/eclipse/features/${fragment_id}_$train_version_timestamp");
375 /*
376 * Zip up language pack
377 */
378 $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip";
379 exec("cd ${babel_language_packs_dir}tmp; zip -r $babel_language_packs_dir$language_pack_name eclipse");
380 /*
381 * Clean up ${babel_language_packs_dir}tmp
382 */
383 exec("rm -rf ${babel_language_packs_dir}tmp");
384 /*
385 * Add project language pack link to language pack links file
386 */
droydfd5d622008-11-10 20:16:39 +0000387 fwrite($language_pack_links_file, "\n\t<li><a href=\"${language_pack_leader}${language_pack_name}\">$language_pack_name</a></li>");
kitlo9c7c62a2008-10-05 16:05:19 +0000388 /*
389 * Jar up this directory as the feature jar
390 */
391 system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename .");
392 /*
393 * Register this feature with the site.xml
394 */
395 $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$feature_version\">";
396 $site_xml .= "\n\t\t<category name=\"Babel Language Packs in $language_name\"/>";
397 $site_xml .= "\n\t</feature>";
398 echo "${leader}Completed language pack for $language_name ($language_iso)\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000399 }
kitlo9c7c62a2008-10-05 16:05:19 +0000400 fwrite($language_pack_links_file, "\n\t</ul>");
gobrien1a8e02f2008-01-30 01:46:26 +0000401 }
gobrien1a8e02f2008-01-30 01:46:26 +0000402 /*
droy0b08d292008-05-28 15:18:11 +0000403 * <site mirrorsURL=... implemented in the weekly build process by sed'ing <site>
gobrien1a8e02f2008-01-30 01:46:26 +0000404 */
kitlo58d8a5a2008-09-24 20:08:44 +0000405 $outp = fopen("${output_dir_for_train}site.xml", "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000406 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
407 "\n<site>" .
408 "\n\t<description url=\"http://babel.eclipse.org/\">" .
409 "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." .
410 "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" .
411 "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." .
412 "\n\t</description>");
kitlo58d8a5a2008-09-24 20:08:44 +0000413 fwrite($outp, $site_xml);
kitlo9c7c62a2008-10-05 16:05:19 +0000414 fwrite($outp, "\n</site>");
kitlo58d8a5a2008-09-24 20:08:44 +0000415 fclose($outp);
kitlo9c7c62a2008-10-05 16:05:19 +0000416
417 fwrite($language_pack_links_file, "\n\t</ul>");
gobrien1a8e02f2008-01-30 01:46:26 +0000418}
gobrien1a8e02f2008-01-30 01:46:26 +0000419echo "Completed generating update site\n";
420
kitlo9c7c62a2008-10-05 16:05:19 +0000421fwrite($language_pack_links_file, "\n</body>\n</html>");
422fclose($language_pack_links_file);
423
gobrien1a8e02f2008-01-30 01:46:26 +0000424/*
kitlo58d8a5a2008-09-24 20:08:44 +0000425 2. what happens if the translation feature includes plug-in fragments for
426 plug-ins that are not in the current image?
427 does it load correctly and ignore those fragments? if so, good
428 A: warnings appear in the run-time error log
429 does it fail to load? if so, then we need to generate different features, perhaps
430 one feature for each plug or else we need to know more about the project
431 distro structure to know which plug-ins to put in each feature
432 what happens if those plug-ins are later added - does it load the strings now?
433 A: probably not
434 3. need to handle different versions of each feature/plugin/platform; generate different
435 language packs for each
436 */
gobrien1a8e02f2008-01-30 01:46:26 +0000437
kitlo58d8a5a2008-09-24 20:08:44 +0000438$alloutput = fopen($output_dir."langpack_output_".date("m_d_Y"), "w");
439fwrite($alloutput,ob_get_contents());
kitlo399df202008-09-30 15:32:25 +0000440?>