From ace7c19c42167bf2c61242890c61082bd4e48991 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 23 Jan 2016 13:20:53 +0100 Subject: L10N: Remove all remaining traces of the interface translation feature ...unless I missed something. --- util/lang.pl | 212 ----------------------------------------------------------- util/vndb.pl | 8 --- 2 files changed, 220 deletions(-) delete mode 100755 util/lang.pl (limited to 'util') diff --git a/util/lang.pl b/util/lang.pl deleted file mode 100755 index 12232e06..00000000 --- a/util/lang.pl +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Cwd 'abs_path'; -our $ROOT; -BEGIN { ($ROOT = abs_path $0) =~ s{/util/lang\.pl$}{}; } - -use lib $ROOT.'/lib'; -use LangFile; - -my $langtxt = "$ROOT/data/lang.txt"; - - -sub usage { - print <<__; -$0 stats - Prints some stats. - -$0 add [] - Adds new (empty) translation lines for language to (defaults to - the global lang.txt) for keys that don't have a TL line yet. - -$0 only [,..] - Makes a copy of lang.txt to and removes all translations except the - ones of langauge (comma-seperated list of tags) - -$0 merge - Merges into lang.txt, copying over all the translations of in - while ignoring any other changes. Keys in not present in - lang.txt are silently ignored. Keys in lang.txt but not in remain - unaffected. Make sure each key in lang.txt already has a line for , - otherwise do an 'add' first. - -$0 reorder ,,.. - Re-orders the translation lines in lang.txt using the specified order. - -$0 cleanup - Higher-level cleanup/canonicalization. Does a bunch of things: - - Adds empty translation lines for languages present in the first key but not in other keys. - - Removes translation lines for languages not present in the first key. - - Reorders all translations to be in the same order as the first key. - - Removes translations that are equivalent to the English text. - TL;DR: Uses the first key in lang.txt as a template for all other keys. - -$0 stage - Puts all changes of into the git index, and leaves everything else untouched. -__ - exit; -} - - -sub stats { - my $r = LangFile->new(read => $langtxt); - my $keys = 0; - my %lang; - while(my $l = $r->read()) { - $keys++ if $l->[0] eq 'key'; - if($l->[0] eq 'tl') { - $lang{$l->[1]} ||= [0,0]; - $lang{$l->[1]}[0]++; - $lang{$l->[1]}[1]++ if $l->[2]; - } - } - print "lang lines sync unsync\n"; - printf "%3s %4d (%3d%%) %4d (%3d%%) %4d\n", $_, - $lang{$_}[0], $lang{$_}[0]/$keys*100, $lang{$_}[1], $lang{$_}[1]/$keys*100, $keys-$lang{$_}[1] - for keys %lang; - printf "Total keys: %d\n", $keys; -} - - -sub add { - my($lang, $file) = @_; - $file ||= $langtxt; - my $r = LangFile->new(read => $file); - my $w = LangFile->new(write => "$file~"); - my $k = 0; - while((my $l = $r->read())) { - if($k && $l->[0] ne 'tl') { - $k = 0; - $w->write('tl', $lang, 0, ''); - } - $k = 1 if $l->[0] eq 'key'; - $k = 0 if $l->[0] eq 'tl' && $l->[1] eq $lang; - $w->write(@$l); - } - $r->close; - $w->close; - rename "$file~", $file or die $!; -} - - -sub only { - my($lang, $out) = @_; - my @lang = split /,/, $lang; - my $r = LangFile->new(read => $langtxt); - my $w = LangFile->new(write => $out); - while((my $l = $r->read())) { - $w->write(@$l) unless $l->[0] eq 'tl' && !grep $_ eq $l->[1], @lang; - } - $r->close; - $w->close; -} - - -sub merge { - my($lang, $file) = @_; - - # read all translations in $lang in $file - my $trans = LangFile->new(read => $file); - my($key, %trans); - while((my $l = $trans->read)) { - $key = $l->[1] if $l->[0] eq 'key'; - $trans{$key} = [ $l->[2], $l->[3] ] if $l->[0] eq 'tl' && $l->[1] eq $lang; - } - $trans->close; - - # now update lang.txt - my $r = LangFile->new(read => $langtxt); - my $w = LangFile->new(write => "$langtxt~"); - while((my $l = $r->read)) { - $key = $l->[1] if $l->[0] eq 'key'; - ($l->[2], $l->[3]) = @{$trans{$key}} if $l->[0] eq 'tl' && $l->[1] eq $lang && $trans{$key}; - $w->write(@$l); - } - $r->close; - $w->close; - rename "$langtxt~", $langtxt or die $!; -} - - -sub reorder { - my @lang = split /,/, shift; - my $r = LangFile->new(read => $langtxt); - my $w = LangFile->new(write => "$langtxt~"); - my($key, %tl); - while((my $l = $r->read)) { - if($key && $l->[0] ne 'tl') { - $tl{$_} && $w->write(@{delete $tl{$_}}) for(@lang); - $w->write(@{$tl{$_}}) for sort keys %tl; - $key = undef; - %tl = (); - } - $key = $l->[1] if $l->[0] eq 'key'; - $tl{$l->[1]} = $l if $l->[0] eq 'tl'; - $w->write(@$l) unless $l->[0] eq 'tl'; - } - $r->close; - $w->close; - rename "$langtxt~", $langtxt or die $!; -} - - -sub cleanup { - my $r = LangFile->new(read => $langtxt); - my $w = LangFile->new(write => "$langtxt~"); - my $key; # current key, undef if not in a TL part - my %tl; # translations of the current key - my @template; # languages and order of the first key - my $havetemp; # set when @template is complete - while((my $l = $r->read)) { - if($key && $l->[0] ne 'tl') { - $havetemp = 1; - for(@template) { - if(!$tl{$_}) { - $w->write('tl', $_, 0, ''); - } elsif($_ ne 'en' && $tl{$_}[3] eq $tl{en}[3]) { - $w->write('tl', $_, 1, ''); - } else { - $w->write(@{$tl{$_}}); - } - } - $key = undef; - %tl = (); - } - $key = $l->[1] if $l->[0] eq 'key'; - $w->write(@$l) unless $l->[0] eq 'tl'; - if($l->[0] eq 'tl') { - $tl{$l->[1]} = $l; - push @template, $l->[1] if !$havetemp; - } - } - $r->close; - $w->close; - rename "$langtxt~", $langtxt or die $!; -} - - -sub stage { - my $lang = shift; - chdir "$ROOT/data"; - rename 'lang.txt', '.lang.txt.tmp' or die $!; - `git checkout lang.txt`; - add $lang; - merge $lang, '.lang.txt.tmp'; - `git add lang.txt`; - rename '.lang.txt.tmp', 'lang.txt'; -} - - -usage if !@ARGV; -my $act = shift; -stats if $act eq 'stats'; -add @ARGV if $act eq 'add'; -only @ARGV if $act eq 'only'; -merge @ARGV if $act eq 'merge'; -reorder @ARGV if $act eq 'reorder'; -cleanup @ARGV if $act eq 'cleanup'; -stage @ARGV if $act eq 'stage'; - diff --git a/util/vndb.pl b/util/vndb.pl index fb01e132..dfb78afa 100755 --- a/util/vndb.pl +++ b/util/vndb.pl @@ -16,7 +16,6 @@ use lib $ROOT.'/lib'; use TUWF ':html', 'kv_validate'; -use VNDB::L10N; use VNDB::Func 'json_decode'; use VNDBUtil 'gtintype'; use SkinFile; @@ -31,10 +30,6 @@ my $skin = SkinFile->new("$ROOT/static/s"); $S{skins} = { map +($_ => [ $skin->get($_, 'name'), $skin->get($_, 'userid') ]), $skin->list }; -# load lang.dat -VNDB::L10N::loadfile(); - - # load settings from global.pl require $ROOT.'/data/global.pl'; @@ -68,9 +63,6 @@ sub reqinit { # check authentication cookies $self->authInit; - # Set language to English - $self->{l10n} = VNDB::L10N->get_handle('en'); - # load some stats (used for about all pageviews, anyway) $self->{stats} = $self->dbStats; -- cgit v1.2.3