11 $YAML::Syck::Headless = 1;
12 $YAML::Syck::ImplicitUnicode = 1;
13 $YAML::Syck::SortKeys = 1;
15 my $languages = LoadFile("config/languages.yml");
17 my $ua = LWP::UserAgent->new(env_proxy => 1);
18 my $response = $ua->get("http://translatewiki.net/wiki/User:Siebrand/langs?uselang=en");
20 die $response->message unless $response->is_success;
22 my $root = HTML::TreeBuilder->new_from_content($response->decoded_content);
23 my $content = $root->look_down("_tag" => "div", "id" => "mw_contentholder");
24 my $list = $content->look_down("_tag" => "ul");
26 for my $item ($list->look_down("_tag" => "li"))
28 my $language = $item->as_trimmed_text;
30 if ($language =~ /^([a-z]+(?:-[a-z]+)*) +- +(.*) +- +(.*)$/i)
33 my $english_name = decode_utf8($2);
34 my $native_name = decode_utf8($3);
36 next if $english_name =~ /\(deprecated:[a-z]+(?:-[a-z]+)*\)$/;
38 if (length($code) == 2 || -f "config/locales/${code}.yml")
40 $languages->{$code}->{english} = $english_name;
41 $languages->{$code}->{native} = $native_name;
46 die "Can't parse: $language";
50 DumpFile("config/languages.yml", $languages);