translate: Restore normal operation with new backend.
diff --git a/common.php b/common.php
index d0c5ca1..0d5bb11 100644
--- a/common.php
+++ b/common.php
@@ -90,6 +90,27 @@
return $phrases;
}
+function combinetgts($tgtmap) {
+ $strmap = array();
+ $combined = array();
+
+ foreach($tgtmap as $tgt => $string) {
+ if ($tgt == '*') { continue; }
+ if (isset($strmap[$string])) {
+ $strmap[$string] .= ",$tgt";
+ } else {
+ $strmap[$string] = "$tgt";
+ }
+ }
+
+ $combined['*'] = $tgtmap['*'];
+ foreach ($strmap as $string => $tgt) {
+ $combined[$tgt] = $string;
+ }
+
+ return $combined;
+}
+
function printphrase($phrase) {
$ret = '';
$ret .= sprintf("<phrase>\n id: %s\n desc:%s\n user:%s\n",
@@ -101,6 +122,7 @@
foreach(array('source', 'dest', 'voice') as $field) {
$ret .= sprintf(" <%s>\n", $field);
if (isset($phrase[$field])) {
+ $phrase[$field] = combinetgts($phrase[$field]);
/* If '*' is empty, we don't catch it on the edit-page */
if (!isset($phrase[$field]['*'])) {
$ret .= " *: \"\"\n";
diff --git a/edit.php b/edit.php
index da78931..22c03d7 100644
--- a/edit.php
+++ b/edit.php
@@ -46,8 +46,8 @@
<input type="hidden" name="lang" value="$lang" />
END;
- $phrases = parselangfile(sprintf("rockbox/apps/lang/%s.lang.update", $lang));
- $english = parselangfile(sprintf("rockbox/apps/lang/%s.lang.update", 'english'));
+ $phrases = parselangfile(sprintf("scratch/%s.lang.update", $lang));
+ $english = parselangfile(sprintf("scratch/%s.lang.update", 'english'));
if ($phrases === false || $english === false) {
printf("<strong>The file %s.lang doesn't exist, or something else went terribly wrong</strong>", $lang);
return false;
diff --git a/submit.php b/submit.php
index 0800340..26b83c6 100644
--- a/submit.php
+++ b/submit.php
@@ -31,7 +31,6 @@
$langs[$lang] = $version;
}
}
- chdir('rockbox'); // chdir into the rockbox dir to get proper diffs
$i = 0;
do {
@@ -47,14 +46,14 @@
}
// Write a header if one exists
- $original_lines = file(sprintf("apps/lang/%s.lang", $_REQUEST['lang']));
+ $original_lines = file(sprintf("rockbox/apps/lang/%s.lang", $_REQUEST['lang']));
foreach($original_lines as $i => $line) {
if (substr($line, 0, 1) == "<") { break; }
fwrite($fp, $line);
}
- $original = parselangfile(sprintf("apps/lang/%s.lang.update", $_REQUEST['lang']));
- $english = parselangfile("apps/lang/english.lang");
+ $original = parselangfile(sprintf("scratch/%s.lang.update", $_REQUEST['lang']));
+ $english = parselangfile("scratch/english.lang");
print("Copyright by individual Rockbox contributors\n");
printf("See\nhttps://git.rockbox.org/cgit/rockbox.git/log/apps/lang/%s.lang\nfor details.\n", $_REQUEST['lang']);
print("May be distributed under the terms of the GNU GPL version 2 or later\n");
@@ -76,7 +75,7 @@
fwrite($fp, printphrase($phrase));
}
fclose($fp);
- $cmd = sprintf("/usr/bin/diff -u -B -w apps/lang/%s.lang %s", escapeshellarg($_REQUEST['lang']), $filename);
+ $cmd = sprintf("/usr/bin/diff -u -B -w rockbox/apps/lang/%s.lang %s", escapeshellarg($_REQUEST['lang']), $filename);
print(shell_exec($cmd));
}
diff --git a/templates/frontpage.tpl b/templates/frontpage.tpl
index 440b3a1..84a55bd 100644
--- a/templates/frontpage.tpl
+++ b/templates/frontpage.tpl
@@ -33,9 +33,12 @@
<td colspan='4'>Language</td>
<td>Last update</td>
<td>Progress</td>
- <td>Missing strings</td>
+ <td>Missing phrases</td>
<td>Changed description</td>
<td>Changed source</td>
+ <td>Missing translation</td>
+ <td>Missing voice</td>
+ <td>Same as English</td>
</tr>
</thead>
{foreach from=$langstats key=langfile item=language}
@@ -61,7 +64,7 @@
{/if}
</td>
<td>
- {if $language.percentage == 100 && $language.desc == 0 && $language.source == 0}
+ {if $language.percentage == 100 && $language.desc == 0 && $language.source == 0 && $language.dest == 0 && $language.voice == 0}
{$language.name}
{else}
<a href='edit.php?lang={$langfile}'>{$language.name}</a>
@@ -77,6 +80,9 @@
<td>{$language.missing}</td>
<td>{$language.desc}</td>
<td>{$language.source}</td>
+ <td>{$language.dest}</td>
+ <td>{$language.voice}</td>
+ <td>{$language.voicedup + $language.destdup}</td>
</tr>
{/foreach}
</table>
diff --git a/update.php b/update.php
index c38474d..8cd6639 100755
--- a/update.php
+++ b/update.php
@@ -79,13 +79,13 @@
$stats = array();
foreach($langs as $lang => $rev) {
- $cmd = sprintf("%s -s rockbox/tools/genlang -u -e=rockbox/apps/lang/english.lang rockbox/apps/lang/%s.lang", PERL, $lang);
+ $cmd = sprintf("%s -s rockbox/tools/updatelang rockbox/apps/lang/english.lang rockbox/apps/lang/%s.lang -", PERL, $lang);
$output = shell_exec($cmd);
// print("$ $cmd\n");
// printf("%s\n", $output);
file_put_contents(sprintf("scratch/%s.lang.update", $lang), $output);
list($lastrev, $lastupdate) = getlastupdated($lang);
- $stat = array('name' => $lang, 'total' => 0, 'missing' => 0, 'desc' => 0, 'source' => 0, 'last_update' => $lastupdate, 'last_update_rev' => $lastrev);
+ $stat = array('name' => $lang, 'total' => 0, 'missing' => 0, 'desc' => 0, 'source' => 0, 'dest' => 0, 'destdup' => 0, 'voice' => 0, 'voicedup' => 0, 'last_update' => $lastupdate, 'last_update_rev' => $lastrev);
foreach(explode("\n", $output) as $line) {
if (preg_match('/### This phrase below was not present in the translated file/', $line) || // DELETEME
preg_match('/### This phrase is missing entirely, copying from english!/', $line)) {
@@ -102,12 +102,12 @@
preg_match("/### The <dest> section for '.*' is blank! Copying from english!/", $line)) {
$stat['dest']++;
} elseif (preg_match("/### The <dest> section for '.*' is identical to english!/", $line)) {
- $stat['destdup']++; break;
+ $stat['destdup']++;
} elseif (preg_match("/### The <voice> section for '.*' is missing! Copying from english!/", $line) ||
preg_match("/### The <voice> section for '.*' is blank! Copying from english!/", $line)) {
$stat['voice']++;
} elseif (preg_match("/### The <voice> section for '.*' is identical to english!/", $line)) {
- $stat['voicedup']++; break;
+ $stat['voicedup']++;
} elseif (preg_match('/<phrase>/', $line)) {
$stat['total']++;
}