gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 1 | <?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 |
droy | 133e746 | 2008-05-13 17:37:24 +0000 | [diff] [blame] | 11 | * Motoki MORT mori-m@mxa.nes.nec.co.jp - patch, bug 227366 |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 12 | * 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 |
kitlo | 7f52267 | 2008-10-21 14:15:54 +0000 | [diff] [blame] | 14 | * Kit Lo (IBM) - patch, bug 251536, newline char missing after copyright comment on first line |
kitlo | 1173dbd | 2008-10-21 15:58:36 +0000 | [diff] [blame] | 15 | * Kit Lo (IBM) - patch, bug 238580, language packs should not include strings that are marked "non-translatable" |
kitlo | 5c9da71 | 2008-10-27 12:45:40 +0000 | [diff] [blame] | 16 | * Kit Lo (IBM) - patch, bug 252140, Illegal token characters in babel fragment names |
atoulme | dbda427 | 2009-01-20 06:04:22 +0000 | [diff] [blame] | 17 | * Antoine Toulme (Intalio, Inc) - patch, bug 256430, Fragments with no host jeopardize Eclipse installation |
kitlo | 47df0c6 | 2009-01-22 15:16:18 +0000 | [diff] [blame] | 18 | * Kit Lo (IBM) - patch, bug 261739, Inconsistent use of language names |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 19 | *******************************************************************************/ |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 20 | |
| 21 | /* |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 22 | * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 23 | */ |
atoulme | 3fa5f5c | 2009-01-20 21:26:16 +0000 | [diff] [blame] | 24 | define("METADATA_GENERATOR_LOCATION", "/home/genie/eclipse"); // you might want to read this value from a config file. Not sure yet. |
gobrien | b854dcb | 2008-01-30 18:50:45 +0000 | [diff] [blame] | 25 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 26 | ini_set("memory_limit", "64M"); |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame^] | 27 | require(dirname(__FILE__) . "/../system/backend_functions.php"); |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 28 | require(dirname(__FILE__) . "/../system/dbconnection.class.php"); |
kitlo | 399df20 | 2008-09-30 15:32:25 +0000 | [diff] [blame] | 29 | $dbc = new DBConnection(); |
| 30 | $dbh = $dbc->connect(); |
droy | b6e25c7 | 2008-07-18 13:01:13 +0000 | [diff] [blame] | 31 | |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame^] | 32 | $work_dir = $addon->callHook('babel_working'); |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 33 | |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame^] | 34 | global $addon; |
| 35 | $context = $addon->callHook('context'); |
gobrien | b854dcb | 2008-01-30 18:50:45 +0000 | [diff] [blame] | 36 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 37 | $work_context_dir = $work_dir . $context . "/"; |
| 38 | $tmp_dir = $work_context_dir . "tmp/"; |
| 39 | $babel_language_packs_dir = $work_context_dir . "babel_language_packs/"; |
| 40 | $output_dir = $work_context_dir . "output/"; |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame^] | 41 | $source_files_dir = dirname(__FILE__) . "/source_files_for_generate/"; |
gobrien | b854dcb | 2008-01-30 18:50:45 +0000 | [diff] [blame] | 42 | |
droy | dfd5d62 | 2008-11-10 20:16:39 +0000 | [diff] [blame] | 43 | # Language pack URL leader, to enable mirrors on download.eclipse.org |
| 44 | $language_pack_leader = ""; |
| 45 | if($context == "live") { |
| 46 | $language_pack_leader = "http://www.eclipse.org/downloads/download.php?r=1&file=/technology/babel/babel_language_packs/"; |
| 47 | } |
| 48 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 49 | $leader = ". . "; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 50 | $timestamp = date("Ymdhis"); |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 51 | |
droy | d157aac | 2008-10-07 21:14:33 +0000 | [diff] [blame] | 52 | $rm_command = "rm -rf $work_dir" . "*"; |
| 53 | exec($rm_command); |
droy | 082976e | 2008-10-07 21:02:23 +0000 | [diff] [blame] | 54 | exec("mkdir -p $output_dir"); |
| 55 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 56 | /* |
| 57 | * Create language pack links file |
| 58 | */ |
| 59 | exec("mkdir -p $babel_language_packs_dir"); |
droy | dfd5d62 | 2008-11-10 20:16:39 +0000 | [diff] [blame] | 60 | $language_pack_links_file = fopen("${babel_language_packs_dir}index.php", "w"); |
| 61 | fwrite($language_pack_links_file, "<?php\n\$pageTitle = \"Babel Language Packs\";\n"); |
droy | 4bef3dc | 2008-11-10 20:55:06 +0000 | [diff] [blame] | 62 | fwrite($language_pack_links_file, "include \$_SERVER['DOCUMENT_ROOT'] . '/eclipse.org-common/themes/Phoenix/header.php';\n"); |
droy | dfd5d62 | 2008-11-10 20:16:39 +0000 | [diff] [blame] | 63 | fwrite($language_pack_links_file, "?>\n"); |
droy | 03d5c46 | 2008-11-10 21:07:01 +0000 | [diff] [blame] | 64 | fwrite($language_pack_links_file, "<div id='maincontent'><div id='midcolumn'>\n"); |
droy | dfd5d62 | 2008-11-10 20:16:39 +0000 | [diff] [blame] | 65 | fwrite($language_pack_links_file, "\n\t<h1>Babel Language Packs</h1>" . |
droy | eb6d9b2 | 2008-11-24 18:42:28 +0000 | [diff] [blame] | 66 | "\n\t<h2>Build ID: $timestamp</h2>" . |
| 67 | "\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." . |
| 68 | "\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>"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 69 | |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 70 | echo "Generating update site\n"; |
droy | eb6d9b2 | 2008-11-24 18:42:28 +0000 | [diff] [blame] | 71 | $train_result = mysql_query("SELECT DISTINCT train_id FROM release_train_projects ORDER BY train_id DESC"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 72 | while (($train_row = mysql_fetch_assoc($train_result)) != null) { |
| 73 | $train_id = $train_row['train_id']; |
| 74 | $train_version = "3.4.0"; |
| 75 | if (strcmp($train_id, "europa") == 0) { |
| 76 | $train_version = "3.3.0"; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 77 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 78 | $train_version_timestamp = "$train_version.v$timestamp"; |
| 79 | $site_xml = ""; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 80 | |
| 81 | $output_dir_for_train = $output_dir . $train_row['train_id'] . "/"; |
| 82 | exec("mkdir $output_dir_for_train"); |
| 83 | exec("mkdir ${output_dir_for_train}features/"); |
| 84 | exec("mkdir ${output_dir_for_train}plugins/"); |
| 85 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 86 | fwrite($language_pack_links_file, "\n\t<h3>Release Train: $train_id</h3>\n\t<ul>"); |
| 87 | |
kitlo | 47df0c6 | 2009-01-22 15:16:18 +0000 | [diff] [blame] | 88 | $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"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 89 | while (($language_row = mysql_fetch_assoc($language_result)) != null) { |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 90 | $language_name = $language_row['name']; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 91 | $language_iso = $language_row['iso_code']; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 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 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 97 | |
| 98 | $site_xml .= "\n\t<category-def name=\"Babel Language Packs in $language_name\" label=\"Babel Language Packs in $language_name\">"; |
| 99 | $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>"; |
| 100 | $site_xml .= "\n\t</category-def>"; |
| 101 | |
| 102 | fwrite($language_pack_links_file, "\n\t<h4>Language: $language_name</h4>\n\t<ul>"); |
| 103 | |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 104 | echo "${leader}Generating language pack for $train_id - $language_name ($language_iso) (language_id=" . $language_id . ")\n"; |
| 105 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 106 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 107 | * Determine which plug-ins need to be in this language pack. |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 108 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 109 | if (strcmp($language_iso, "en_AA") == 0) { |
| 110 | $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name |
| 111 | FROM files AS f |
| 112 | INNER JOIN strings AS s ON f.file_id = s.file_id |
| 113 | INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version) |
| 114 | WHERE f.is_active |
| 115 | AND v.train_id = '" . $train_row['train_id'] . "'"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 116 | } else { |
| 117 | $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name |
| 118 | FROM files AS f |
| 119 | INNER JOIN strings AS s ON f.file_id = s.file_id |
| 120 | INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active) |
| 121 | INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version) |
| 122 | WHERE t.language_id = " . $language_id . " |
| 123 | AND f.is_active |
| 124 | AND v.train_id = '" . $train_row['train_id'] . "'"); |
| 125 | } |
| 126 | |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 127 | $plugins = array(); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 128 | $projects = array(); |
| 129 | $project_versions = array(); |
| 130 | $pseudo_translations_indexes = array(); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 131 | while (($file_row = mysql_fetch_assoc($file_result)) != null) { |
| 132 | # save original filename |
| 133 | $file_row['origname'] = $file_row['name']; |
| 134 | |
droy | 02c430a | 2008-06-02 19:42:08 +0000 | [diff] [blame] | 135 | # strip useless CVS structure before the plugin name (bug 221675 c14): |
| 136 | $pattern = '/^([a-zA-Z0-9\/_-])+\/([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)(.*)\.properties$/i'; |
| 137 | $replace = '${2}.${3}${4}.properties'; |
| 138 | $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 139 | |
droy | 02c430a | 2008-06-02 19:42:08 +0000 | [diff] [blame] | 140 | # strip source folder (bug 221675) (org.eclipse.plugin/source_folder/org/eclipse/plugin) |
| 141 | $pattern = '/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9\._-]+)(.*)\/(\1)([\.\/])(\2)([\.\/])(.*)\.properties$/i'; |
| 142 | $replace = '${1}.${2}.${3}/${5}${6}${7}${8}${9}.properties'; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 143 | $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 144 | |
| 145 | if (preg_match("/^([a-zA-Z0-9\.]+)\/(.*)$/", $file_row['name'], $matches)) { |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 146 | $file_row['subname'] = $matches[2]; |
| 147 | $plugins[$matches[1]][] = $file_row; |
| 148 | } else { |
| 149 | echo " WARNING: no plug-in name found in file " . $file_row['file_id'] . " \"" . $file_row['name'] . "\"\n"; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 150 | } |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 151 | } |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 152 | |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 153 | /* |
| 154 | * Generate one plug-in fragment for each plug-in |
| 155 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 156 | foreach ($plugins as $plugin_name => $plugin_row) { |
| 157 | echo "${leader}${leader}Generating plug-in fragment $plugin_name\n"; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 158 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 159 | * Clean and create the temporary directory |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 160 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 161 | if (file_exists($tmp_dir)) { |
| 162 | exec("rm -rf $tmp_dir; mkdir $tmp_dir"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 163 | } else { |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 164 | exec("mkdir $tmp_dir"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 165 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 166 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 167 | * Generate each *.properties file |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 168 | */ |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 169 | foreach ($plugin_row as $properties_file) { |
| 170 | /* |
| 171 | * Convert the filename to *_lang.properties, e.g., foo_fr.properties |
| 172 | */ |
| 173 | $filename = $properties_file['subname']; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 174 | if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) { |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 175 | $filename = $matches[1] . '_' . $language_iso . '.properties'; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 176 | } |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 177 | echo "${leader}${leader}${leader}Generating properties file $filename (file_id=" . $properties_file['file_id'] . ")\n"; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 178 | /* |
| 179 | * Create any needed sub-directories |
| 180 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 181 | $fullpath = $tmp_dir . $filename; |
| 182 | preg_match("/^((.*)\/)?(.+?)$/", $fullpath, $matches); |
| 183 | exec("mkdir -p \"" . $matches[1] . "\""); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 184 | /* |
| 185 | * Start writing to the file |
| 186 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 187 | $outp = fopen($fullpath, "w"); |
kitlo | c42941d | 2008-11-20 15:33:00 +0000 | [diff] [blame] | 188 | fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 189 | if (strcmp($language_iso, "en_AA") == 0) { |
| 190 | $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] . |
| 191 | " AND is_active AND non_translatable = 0"; |
| 192 | $strings_result = mysql_query($sql); |
| 193 | while (($strings_row = mysql_fetch_assoc($strings_result)) != null) { |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 194 | fwrite($outp, "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] . |
| 195 | ":" . $strings_row['value']); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 196 | |
| 197 | $value = htmlspecialchars($strings_row['value']); |
| 198 | if (strlen($value) > 100) { |
| 199 | $value = substr($value, 0, 100) . " ..."; |
| 200 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 201 | $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" . |
| 202 | $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" . |
| 203 | $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" . |
| 204 | $properties_file['project_id'] . $strings_row['string_id'] . "</a> " . $value . "</li>"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 205 | } |
| 206 | } else { |
| 207 | $sql = "SELECT |
| 208 | strings.name AS 'key', |
| 209 | strings.value AS orig, |
| 210 | translations.value AS trans |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 211 | FROM strings, translations |
| 212 | WHERE strings.string_id = translations.string_id |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 213 | AND strings.file_id = " . $properties_file['file_id'] . " |
kitlo | 1173dbd | 2008-10-21 15:58:36 +0000 | [diff] [blame] | 214 | AND strings.is_active |
| 215 | AND strings.non_translatable = 0 |
| 216 | AND translations.language_id = " . $language_id . " |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 217 | AND translations.is_active"; |
| 218 | $strings_result = mysql_query($sql); |
| 219 | while (($strings_row = mysql_fetch_assoc($strings_result)) != null) { |
kitlo | 7f52267 | 2008-10-21 14:15:54 +0000 | [diff] [blame] | 220 | fwrite($outp, "\n" . $strings_row['key'] . "="); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 221 | # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "="; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 222 | if ($strings_row['trans']) { |
| 223 | # json_encode returns the string with quotes fore and aft. Need to strip them. |
| 224 | # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans'])); |
| 225 | # $tr_string = str_replace('\\\\', '\\', $tr_string); |
| 226 | $tr_string = toescapedunicode($strings_row['trans']); |
| 227 | fwrite($outp, $tr_string); |
| 228 | # echo $strings_row['trans']; |
| 229 | } else { |
| 230 | fwrite($outp, $strings_row['orig']); |
| 231 | } |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 232 | } |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 233 | } |
| 234 | /* |
| 235 | * Finish the properties file |
| 236 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 237 | fclose($outp); |
| 238 | echo "${leader}${leader}${leader}Completed properties file $filename\n"; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 239 | } |
| 240 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 241 | * Copy in the various legal files |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 242 | */ |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 243 | exec("cp ${source_files_dir}about.html $tmp_dir"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 244 | /* |
| 245 | * Generate the META-INF/MANIFEST.MF file |
| 246 | */ |
| 247 | $parent_plugin_id = $plugin_name; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 248 | $project_id = $properties_file['project_id']; |
kitlo | 5c9da71 | 2008-10-27 12:45:40 +0000 | [diff] [blame] | 249 | $fragment_id = "$parent_plugin_id.nl_$language_iso"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 250 | $fragment_filename = "${fragment_id}_$train_version_timestamp.jar"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 251 | |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 252 | $plugins[$plugin_name]['id'] = $fragment_id; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 253 | $plugins[$plugin_name]['version'] = $train_version_timestamp; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 254 | |
| 255 | exec("mkdir $tmp_dir/META-INF" ); |
| 256 | $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w"); |
| 257 | fwrite($outp, "Manifest-Version: 1.0\n"); |
| 258 | fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n"); |
| 259 | fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 260 | fwrite($outp, "Bundle-Version: $train_version_timestamp\n"); |
| 261 | fwrite($outp, "Bundle-Vendor: Eclipse.org\n"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 262 | fwrite($outp, "Fragment-Host: $parent_plugin_id\n"); |
| 263 | fclose($outp); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 264 | /* |
| 265 | * Jar up this directory as the fragment plug-in jar |
| 266 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 267 | system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename ."); |
| 268 | echo "${leader}${leader}Completed plug-in fragment $plugin_name\n"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 269 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 270 | $projects[$project_id][] = $fragment_id; |
| 271 | $project_versions[$project_id] = $properties_file['version']; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 272 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 273 | foreach ($projects as $project_id => $fragment_ids) { |
| 274 | /* |
| 275 | * Sort fragment names |
| 276 | */ |
| 277 | asort($fragment_ids); |
| 278 | /* |
| 279 | * Create ${babel_language_packs_dir}tmp |
| 280 | */ |
| 281 | exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features"); |
| 282 | exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/plugins"); |
| 283 | /* |
| 284 | * Clean and create the temporary directory |
| 285 | */ |
| 286 | if (file_exists($tmp_dir)) { |
| 287 | exec("rm -rf $tmp_dir; mkdir $tmp_dir"); |
| 288 | } else { |
| 289 | exec("mkdir $tmp_dir"); |
| 290 | } |
| 291 | /* |
| 292 | * Create the feature.xml |
| 293 | * |
| 294 | * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented |
| 295 | * |
| 296 | * <url> |
| 297 | * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" /> |
| 298 | * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" /> |
| 299 | * </url> |
| 300 | */ |
kitlo | 5c9da71 | 2008-10-27 12:45:40 +0000 | [diff] [blame] | 301 | $feature_id = "org.eclipse.babel.nls_${project_id}_$language_iso"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 302 | $feature_filename = "${feature_id}_$train_version_timestamp.jar"; |
| 303 | |
| 304 | $project_version = $project_versions[$project_id]; |
| 305 | $sql = "SELECT pct_complete |
| 306 | FROM project_progress |
| 307 | WHERE project_id = \"$project_id\" |
| 308 | AND version = \"$project_version\" |
| 309 | AND language_id = $language_id"; |
| 310 | $project_pct_complete_result = mysql_query($sql); |
| 311 | $project_pct_complete = mysql_result($project_pct_complete_result, 0); |
| 312 | if (strcmp($language_iso, "en_AA") == 0) { |
| 313 | $project_pct_complete = 100; |
| 314 | } |
| 315 | |
| 316 | $outp = fopen("$tmp_dir/feature.xml", "w"); |
| 317 | fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" . |
| 318 | "\n<feature" . |
| 319 | "\n\tid=\"$feature_id\"" . |
| 320 | "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" . |
| 321 | "\n\timage=\"eclipse_update_120.jpg\"" . |
| 322 | "\n\tprovider-name=\"%providerName\"" . |
| 323 | "\n\tversion=\"$train_version_timestamp\">" . |
| 324 | "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" . |
| 325 | "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" . |
| 326 | "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" ); |
| 327 | foreach ($fragment_ids as $fragment_id) { |
| 328 | $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar"; |
| 329 | $size = filesize($jar_name); |
| 330 | fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " . |
| 331 | "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />"); |
| 332 | /* |
| 333 | * Copy the plugin to ${babel_language_packs_dir}tmp |
| 334 | */ |
| 335 | exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir}tmp/eclipse/plugins"); |
| 336 | } |
| 337 | fwrite($outp, "\n</feature>"); |
| 338 | fclose($outp); |
| 339 | /* |
| 340 | * Copy in the various legal files |
| 341 | */ |
| 342 | exec("cp ${source_files_dir}about.html $tmp_dir"); |
| 343 | exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir"); |
| 344 | exec("cp ${source_files_dir}epl-v10.html $tmp_dir"); |
| 345 | exec("cp ${source_files_dir}feature.properties $tmp_dir"); |
| 346 | exec("cp ${source_files_dir}license.html $tmp_dir"); |
| 347 | /* |
| 348 | * Copy in the Babel Pseudo Translations Index file |
| 349 | */ |
| 350 | if (strcmp($language_iso, "en_AA") == 0) { |
| 351 | $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w"); |
| 352 | fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" . |
| 353 | "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" . |
| 354 | "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" . |
| 355 | "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" . |
| 356 | "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>"); |
| 357 | foreach ($pseudo_translations_indexes[$project_id] as $index) { |
| 358 | fwrite($pseudo_translations_index_file, $index); |
| 359 | } |
droy | 03d5c46 | 2008-11-10 21:07:01 +0000 | [diff] [blame] | 360 | fwrite($pseudo_translations_index_file, "\n\t</ul>\n</div></div></body>\n</html>"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 361 | fclose($pseudo_translations_index_file); |
| 362 | exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir"); |
| 363 | exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html"); |
| 364 | } |
| 365 | /* |
| 366 | * Copy the feature to ${babel_language_packs_dir}tmp before jar'ing up |
| 367 | */ |
kitlo | c42941d | 2008-11-20 15:33:00 +0000 | [diff] [blame] | 368 | exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp"); |
| 369 | exec("cd $tmp_dir; cp * ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 370 | /* |
| 371 | * Zip up language pack |
| 372 | */ |
| 373 | $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip"; |
| 374 | exec("cd ${babel_language_packs_dir}tmp; zip -r $babel_language_packs_dir$language_pack_name eclipse"); |
| 375 | /* |
| 376 | * Clean up ${babel_language_packs_dir}tmp |
| 377 | */ |
| 378 | exec("rm -rf ${babel_language_packs_dir}tmp"); |
| 379 | /* |
| 380 | * Add project language pack link to language pack links file |
| 381 | */ |
kitlo | 18ebeee | 2008-11-20 15:45:34 +0000 | [diff] [blame] | 382 | fwrite($language_pack_links_file, "\n\t<li><a href=\"${language_pack_leader}${language_pack_name}\">$language_pack_name ($project_pct_complete%)</a></li>"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 383 | /* |
| 384 | * Jar up this directory as the feature jar |
| 385 | */ |
| 386 | system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename ."); |
| 387 | /* |
| 388 | * Register this feature with the site.xml |
| 389 | */ |
kitlo | c42941d | 2008-11-20 15:33:00 +0000 | [diff] [blame] | 390 | $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$train_version_timestamp\">"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 391 | $site_xml .= "\n\t\t<category name=\"Babel Language Packs in $language_name\"/>"; |
| 392 | $site_xml .= "\n\t</feature>"; |
| 393 | echo "${leader}Completed language pack for $language_name ($language_iso)\n"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 394 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 395 | fwrite($language_pack_links_file, "\n\t</ul>"); |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 396 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 397 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 398 | * <site mirrorsURL=... implemented in the weekly build process by sed'ing <site> |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 399 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 400 | $outp = fopen("${output_dir_for_train}site.xml", "w"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 401 | fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . |
| 402 | "\n<site>" . |
| 403 | "\n\t<description url=\"http://babel.eclipse.org/\">" . |
| 404 | "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." . |
| 405 | "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" . |
| 406 | "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." . |
| 407 | "\n\t</description>"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 408 | fwrite($outp, $site_xml); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 409 | fwrite($outp, "\n</site>"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 410 | fclose($outp); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 411 | |
| 412 | fwrite($language_pack_links_file, "\n\t</ul>"); |
atoulme | dbda427 | 2009-01-20 06:04:22 +0000 | [diff] [blame] | 413 | |
| 414 | // now generate the metadata and add the non-greedy tags |
atoulme | 09ce464 | 2009-01-21 07:46:06 +0000 | [diff] [blame] | 415 | |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 416 | system("sh " . dirname(__FILE__) . "/runMetadata.sh ". |
atoulme | 09ce464 | 2009-01-21 07:46:06 +0000 | [diff] [blame] | 417 | METADATA_GENERATOR_LOCATION . " ${output_dir_for_train} "); |
atoulme | c86be15 | 2009-01-21 22:36:31 +0000 | [diff] [blame] | 418 | system("xsltproc -o ${output_dir_for_train}content.xml ". |
atoulme | b0f0e50 | 2009-01-21 17:27:25 +0000 | [diff] [blame] | 419 | dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml"); |
atoulme | 99b653c | 2009-01-23 09:36:23 +0000 | [diff] [blame] | 420 | system("cd ${output_dir_for_train} ; jar -fc content.jar artifacts.xml content.xml"); |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 421 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 422 | echo "Completed generating update site\n"; |
| 423 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 424 | fwrite($language_pack_links_file, "\n</body>\n</html>"); |
| 425 | fclose($language_pack_links_file); |
| 426 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 427 | /* |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 428 | 2. what happens if the translation feature includes plug-in fragments for |
| 429 | plug-ins that are not in the current image? |
| 430 | does it load correctly and ignore those fragments? if so, good |
| 431 | A: warnings appear in the run-time error log |
| 432 | does it fail to load? if so, then we need to generate different features, perhaps |
| 433 | one feature for each plug or else we need to know more about the project |
| 434 | distro structure to know which plug-ins to put in each feature |
| 435 | what happens if those plug-ins are later added - does it load the strings now? |
| 436 | A: probably not |
| 437 | 3. need to handle different versions of each feature/plugin/platform; generate different |
| 438 | language packs for each |
| 439 | */ |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 440 | |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 441 | $alloutput = fopen($output_dir."langpack_output_".date("m_d_Y"), "w"); |
| 442 | fwrite($alloutput,ob_get_contents()); |
kitlo | 399df20 | 2008-09-30 15:32:25 +0000 | [diff] [blame] | 443 | ?> |