summaryrefslogtreecommitdiff
path: root/debian/update_languages
blob: d9fa579042ef6937d14ee7e11366aed1b0082282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl -w
use strict;

die "Must be executed in the 'debian' subdir" unless -d 'upstream';

`rm -f upstream/phpbb3_l10n-*.info`;

my @lists;
my @langs;

my $index='https://www.phpbb.com/languages/index.php';
my $trans='/customise/db/translation/';
my $downl='https://www.phpbb.com/customise/db/download/';

# Get language pages and other list pages
open DOWNLOADS, "wget -q -O- $index|";
while (<DOWNLOADS>) {
	push @langs, $1 if m,<a href="$trans(.+?)/\?sid=\w+?">,;
	push @lists, $1 if m,<a href="\./\.\./languages/index.php\?sid=\w+&amp;(start=\d+)" role="button">,;
}
close DOWNLOADS;

# Get other language pages
for (@lists) {
	open DOWNLOADS, "wget -q -O- $index\?$_|";
	while (<DOWNLOADS>) {
		push @langs, $1 if m,<a href="$trans(.+?)/\?sid=\w+?">,
	}
	close DOWNLOADS;
}

# Get information about language pack
for (@langs) {
	open DOWNLOADS, "wget -q -O- https://www.phpbb.com/customise/db/translation/$_|";
	my ($url,$code,$md5);
	$md5 ='';
	while (<DOWNLOADS>) {
		$url = $1 if m,<a class="download-button" href="($downl\d+)\?sid=\w+",;
		$md5 = 0 if m,<dt>MD5 checksum:</dt>,;
		if ($md5 eq 0) {
			$md5 = $1 if m,<dd>(\w+)</dd>,;
		}
		$code = $1 if m,<strong>ISO Code</strong> (.+)\n,;
	}
	close DOWNLOADS;
	open INFO, "> upstream/phpbb3_l10n-$code.info";
	print INFO "Url=$url\n";
	print INFO "Md5=$md5\n";
	print INFO "Copyright=GPL-2\n";
	print INFO "Include=yes\n";
	close INFO;
}