]> git.openstreetmap.org Git - rails.git/commit
Delete redundant translations from localised files.
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 23 Sep 2009 17:29:29 +0000 (17:29 +0000)
committerÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 23 Sep 2009 17:29:29 +0000 (17:29 +0000)
commitd5c71f697b836adaaa62861c56f6b4f09512a449
tree7faabdcadedaa59107544a86305ae875cc2f6bb3
parentaeca7367be48cb4a849c739e795b2297c8c63649
Delete redundant translations from localised files.

I used this script:

{{{
#!/usr/bin/env perl
use feature ':5.10';
use strict;
use warnings;
use YAML::Syck qw(Load LoadFile Dump DumpFile);
use File::Slurp qw(slurp);
use Data::Dump 'dump';
use Encode qw(decode);
use autodie;

$YAML::Syck::Headless = 1;
$YAML::Syck::SortKeys = 1;
$YAML::Syck::ImplicitUnicode = 1;

my %lang;
chdir 'locales';
my @yml = glob "*.yml";
my @lang = map { s/\.yml//; $_ } @yml;

for my $lang (@lang) {
    say "Loading $lang";
    $lang{$lang} = LoadFile("$lang.yml")->{$lang};
}

for my $lang (grep { $_ ne 'en' } @lang) {
    while (my ($k, $v) = each %{ $lang{ $lang } }) {
        if ($lang{ $lang }->{$k} eq $lang{ en }->{$k}
            or (exists $lang{ $lang }->{$k} and not exists $lang{ en }->{$k})) {
            delete $lang{ $lang }->{$k};
        }
    }
}

for my $lang (@lang) {
    DumpFile("$lang.yml", { $lang => $lang{$lang} }) or die "arghl";
}
}}}
25 files changed:
config/potlatch/locales/br.yml
config/potlatch/locales/cs.yml
config/potlatch/locales/cz.yml
config/potlatch/locales/da.yml
config/potlatch/locales/de.yml
config/potlatch/locales/en.yml
config/potlatch/locales/es.yml
config/potlatch/locales/fi.yml
config/potlatch/locales/fr.yml
config/potlatch/locales/hu.yml
config/potlatch/locales/is.yml
config/potlatch/locales/it.yml
config/potlatch/locales/ja.yml
config/potlatch/locales/ko.yml
config/potlatch/locales/lolcat.yml
config/potlatch/locales/nl.yml
config/potlatch/locales/no.yml
config/potlatch/locales/pt-BR.yml
config/potlatch/locales/ro.yml
config/potlatch/locales/ru.yml
config/potlatch/locales/sv.yml
config/potlatch/locales/tr.yml
config/potlatch/locales/vi.yml
config/potlatch/locales/zh-HANS.yml
config/potlatch/locales/zh-HANT.yml