blob: 769fc95c49c35dabf54c7271d72cd8b9951feea2 [file] [log] [blame]
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00001<?php
2error_reporting(E_ALL);
3require_once('common.php');
4
5function submit() {
6 header("Content-type: text/plain;charset=UTF-8");
7 header(sprintf("Content-Disposition: attachment; filename=%s.diff", $_REQUEST['lang']));
Jonas Häggqvist04e454b2010-01-31 01:50:52 +00008 chdir('rockbox'); // chdir into the rockbox dir to get proper diffs
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00009
10 $i = 0;
11 do {
12 $filename = sprintf("apps/lang/%s.lang%s.new", $_REQUEST['lang'], $i == 0 ? '' : '.'.$i);
13 $i++;
14 } while (file_exists($filename));
15
16 $fp = fopen($filename, 'w');
17 $langs = array();
18 if (file_exists(VERSIONS)) {
19 foreach(file(VERSIONS) as $line) {
20 list($lang, $version) = explode(":", trim($line));
21 $langs[$lang] = $version;
22 }
23 }
24
25 // Write a header if one exists
26 $original_lines = file(sprintf("apps/lang/%s.lang", $_REQUEST['lang']));
27 foreach($original_lines as $i => $line) {
28 if (substr($line, 0, 1) == "<") { break; }
29 fwrite($fp, $line);
30 }
31
32 $original = parselangfile(sprintf("apps/lang/%s.lang.update", $_REQUEST['lang']));
33 $english = parselangfile("apps/lang/english.lang");
34 print("Copyright by individual Rockbox contributors\n");
Dominik Riebeling091c3242012-05-19 19:12:11 +020035 printf("See\nhttp://git.rockbox.org/?p=rockbox.git;a=history;f=apps/lang/%s.lang;hb=HEAD\nfor details.\n", $_REQUEST['lang']);
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000036 print("May be distributed under the terms of the GNU GPL version 2 or later\n");
37 print("This file generated by http://translate.rockbox.org/\n\n");
38 printf("This translation was based on SVN revision %d of the original.\n\n", $langs[$_REQUEST['lang']]);
39
40 foreach($original as $id => $phrase) {
41 foreach(array('dest', 'voice') as $type) {
42 if (isset($_POST['phrases'][$id])) {
43 if (isset($_POST['phrases'][$id][$type]))
44 $phrase[$type] = $_POST['phrases'][$id][$type];
45 else
46 unset($phrase[$type]);
47 }
48 }
49 if (strtolower($english[$id]['phrase']['desc']) == "deprecated") {
50 $phrase = $english[$id];
51 }
52 fwrite($fp, printphrase($phrase));
53 }
54 fclose($fp);
55 $cmd = sprintf("/usr/bin/diff -u -B -w apps/lang/%s.lang %s", escapeshellarg($_REQUEST['lang']), $filename);
56 print(shell_exec($cmd));
57}
58
59submit();
60?>