aboutsummaryrefslogtreecommitdiffstats
path: root/bin/emptyhomes/make_welsh_po
diff options
context:
space:
mode:
Diffstat (limited to 'bin/emptyhomes/make_welsh_po')
-rwxr-xr-xbin/emptyhomes/make_welsh_po116
1 files changed, 0 insertions, 116 deletions
diff --git a/bin/emptyhomes/make_welsh_po b/bin/emptyhomes/make_welsh_po
deleted file mode 100755
index 568ccdcde..000000000
--- a/bin/emptyhomes/make_welsh_po
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-# Given a translation of the Empty Homes version of the FixMyStreet .po file,
-# fix it all up to go direct from FixMyStreet -> EH translation.
-
-use POSIX;
-use FindBin;
-use lib "$FindBin::Bin/../../perllib";
-use PoChange;
-
-chdir("$FindBin::Bin/../../locale");
-
-# First read in translation and match up.
-open(INPO, 'cy_GB.UTF-8/LC_MESSAGES/EmptyHomes.po') or die $!;
-
-my $state = 'start';
-my $msgid = '';
-my $fuzzy = 0;
-my $msgstr;
-my %lookup;
-while (<INPO>) {
- if (m/^#, fuzzy/) {
- $fuzzy = 1;
- } elsif (m/^#/) {
- # comment or blank line
- } elsif (m/^\s+$/) {
- # blank line separates translations
- $msgid =~ s/"\n"//g;
- $lookup{$msgid} = [ $msgstr, $fuzzy ];
- $state = 'msgid';
- $msgid = "";
- $fuzzy = 0;
- } elsif ($state eq 'msgid' && (m/^msgstr "/ || m/^msgstr\[0\] "/)) {
- $msgstr = $_;
- $state = 'msgstr';
- } elsif ($state eq 'msgstr') {
- $msgstr .= $_;
- } elsif ($state eq 'msgid') {
- $msgid .= $_;
- }
-}
-$lookup{$msgid} = [ $msgstr, $fuzzy ];
-close INPO;
-
-mkdir("en_GB.UTF-8");
-mkdir("en_GB.UTF-8/LC_MESSAGES");
-mkdir("cy_GB.UTF-8");
-mkdir("cy_GB.UTF-8/LC_MESSAGES");
-
-open(MAINPO, 'FixMyStreet.po') or die;
-open(OUTPO, ">cy_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.po") or die;
-
-print OUTPO "# AUTOMATICALLY GENERATED by make_welsh_po, do not edit\n\n";
-
-my $buffer = "";
-my $start = 0;
-while(<MAINPO>) {
- if (!$start) {
- s/#, fuzzy/#/;
- }
- if (m/"Last-Translator: FULL NAME/) {
- $_ = '"Last-Translator: mysociety/bin/emptyhomes/make_welsh_po\\n"'."\n";
- }
- if (m/"PO-Revision-Date: YEAR-MO-DA/) {
- my $time = POSIX::strftime("%Y-%m-%d %H:%M%z", localtime(time()));
- $_ = '"PO-Revision-Date: '.$time.'\\n"'."\n";
- }
- if (m/"Language-Team: LANGUAGE/) {
- $_ = '"Language-Team: mySociety\\n"'."\n";
- }
- if (m/"Plural-Forms: nplurals=/) {
- $_ = '"Plural-Forms: nplurals=2; plural=n != 1;\\n"'."\n";
- }
-
- if (m/^#/) {
- # comment or blank line
- print OUTPO $_;
- } elsif (m/^\s+$/) {
- # blank line
- $start = 1;
- $buffer = "";
- print OUTPO $_;
- } elsif ($start && (m/^msgstr "/ || m/^msgstr\[0\] "/)) {
- # start of translated text - translate English into Empty Homes language
- my $new_buffer = PoChange::fixmystreet_to_reportemptyhomes($buffer);
- $new_buffer =~ s/"\n"//g;
-
- if ($lookup{$new_buffer} && $lookup{$new_buffer}[1]) {
- print OUTPO "#, fuzzy\n";
- }
-
- print OUTPO $buffer;
- if ($lookup{$new_buffer}) {
- print OUTPO $lookup{$new_buffer}[0];
- } else {
- if (m/^msgstr\[0\] ""/) {
- $new_buffer =~ s/^msgid "/msgstr[0] "/m;
- $new_buffer =~ s/^msgid_plural "/msgstr[1] "/m;
- $_ = <MAINPO>; # skip untranslated plural
- } else {
- $new_buffer =~ s/^msgid "/msgstr "/;
- }
- print OUTPO $new_buffer;
- }
-
- $buffer = "";
- } elsif (!$start) {
- print OUTPO $_;
- } else {
- $buffer .= $_;
- }
-}
-