Bug 251435 - Populate translation hints if string has no translations Signed-off-by: droy <denis.roy@eclipse-foundation.org>
diff --git a/html/callback/getCurrentStringTranslation.php b/html/callback/getCurrentStringTranslation.php index 4c2c344..475e188 100644 --- a/html/callback/getCurrentStringTranslation.php +++ b/html/callback/getCurrentStringTranslation.php
@@ -1,6 +1,6 @@ <?php /******************************************************************************* - * Copyright (c) 2007 Eclipse Foundation and others. + * Copyright (c) 2007-2018 Eclipse Foundation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -54,8 +54,7 @@ files.version = '".addslashes($version)."' group by translations.version order by translations.version desc - limit 1 - "; + limit 1"; //print $query; @@ -117,21 +116,6 @@ AND T.is_active = 1 "; - -//INSERT INTO translations SELECT S.string_id, 2, "Some Enhanced Text", other fields..... FROM strings AS S inner join files AS F on F.file_id = S.file_id inner join translations AS T on T.string_id = S.string_id where F.project_id = "eclipse" AND F.name=(SELECT files.name FROM files where file_id = 7) AND S.name="pluginName" and T.value = "Some Old Text" AND T.is_active = 1 - -//print $query; - - -/* -$res = mysql_query($query,$dbh); -while($same_trans = mysql_fetch_array($res, MYSQL_ASSOC)){ - print "<pre>--"; - print_r($same_trans); - print "</pre>"; -} -*/ - ?> <form id='translation-form'> @@ -145,7 +129,25 @@ </div> <h4 id="translation-hints-title">Translation Hints</h4> <div id="translation-hints" style='overflow-x: hidden; overflow-y: auto; height: 75px;'> - Select some English text above to find similar translations. + Select some English text above to find similar translations + <?php + $q_th = "SELECT DISTINCT t.value + FROM translations as t + INNER JOIN strings AS s ON s.string_id = t.string_id + INNER JOIN files AS f ON s.file_id = f.file_id + WHERE s.value like '" . addslashes(substr($line['string_value'], 0, 15)) . "%' + AND t.is_active + AND t.language_id = '".addslashes($language)."' + ORDER BY LENGTH(t.value) ASC LIMIT 10"; + $res_th = mysql_query($q_th, $dbh); + if(mysql_affected_rows($dbh) > 0) { + echo ", or use from the following:<ul>"; + while($line = mysql_fetch_array($res_th, MYSQL_ASSOC)){ + echo "<li>", $line['value'], "</li>"; + } + echo "</ul>"; + } + ?> </div> <input id='non-translatable-checkbox' type=checkbox name="non_translatable_string" <?= $line['non_translatable'] ? 'checked' : '' ;?>>Non-Translatable
diff --git a/html/callback/getTranslationHints.php b/html/callback/getTranslationHints.php index 9ff940a..93f8fcf 100644 --- a/html/callback/getTranslationHints.php +++ b/html/callback/getTranslationHints.php
@@ -1,6 +1,6 @@ <?php /******************************************************************************* - * Copyright (c) 2008 Eclipse Foundation and others. + * Copyright (c) 2008-2018 Eclipse Foundation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,29 +28,13 @@ return false; } -$train_id = ""; -$query = "SELECT train_id FROM release_trains ORDER BY train_version LIMIT 2"; -$res = mysql_query($query,$dbh); -while($line = mysql_fetch_array($res, MYSQL_ASSOC)){ - if($train_id != "") { - $train_id .= ","; - } - $train_id .= "'" . $line['train_id'] . "'"; -} - -if($train_id == "") { - $train_id = 'kepler'; -} - //At first, performs front match $query = "SELECT DISTINCT t.value FROM translations as t INNER JOIN strings AS s ON s.string_id = t.string_id INNER JOIN files AS f ON s.file_id = f.file_id - INNER JOIN release_train_projects AS tr ON tr.project_id = f.project_id AND tr.version = f.version WHERE s.value like '" . addslashes($tr_string). "%' AND t.is_active - AND tr.train_id IN (" . $train_id . ") AND t.language_id = '".addslashes($language)."' ORDER BY LENGTH(t.value) ASC LIMIT 15";