aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/make_emptyhomes_po4
-rwxr-xr-xbin/make_emptyhomes_welsh_po112
2 files changed, 114 insertions, 2 deletions
diff --git a/bin/make_emptyhomes_po b/bin/make_emptyhomes_po
index 4897ba451..bcb674a23 100755
--- a/bin/make_emptyhomes_po
+++ b/bin/make_emptyhomes_po
@@ -16,10 +16,10 @@ open(EHAPO, ">FixMyStreet-EmptyHomes.po") or die "";
open(NEWPO, ">en_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.po") or die "";
print NEWPO "# AUTOMATICALLY GENERATED by make_emptyhomes_po, do not edit\n";
-print NEWPO "\n";
+print NEWPO "#\n";
print EHAPO "# AUTOMATICALLY GENERATED by make_emptyhomes_po, do not edit\n";
-print EHAPO "\n";
+print EHAPO "#\n";
my $buffer = "";
my $start = 0;
diff --git a/bin/make_emptyhomes_welsh_po b/bin/make_emptyhomes_welsh_po
new file mode 100755
index 000000000..40f4526cd
--- /dev/null
+++ b/bin/make_emptyhomes_welsh_po
@@ -0,0 +1,112 @@
+#!/usr/bin/perl -w
+use strict;
+
+# 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;
+
+chdir("$FindBin::Bin/../../locale");
+mkdir("en_GB.UTF-8");
+mkdir("en_GB.UTF-8/LC_MESSAGES");
+mkdir("cy_GB.UTF-8");
+mkdir("cy_GB.UTF-8/LC_MESSAGES");
+
+# First read in translation and match up.
+open(INPO, shift) or die;
+
+my $state = 'start';
+my $msgid = '';
+my $msgstr;
+my %lookup;
+while (<INPO>) {
+ if (m/^#/) {
+ # comment or blank line
+ } elsif (m/^\s+$/) {
+ # blank line separates translations
+ $lookup{$msgid} = $msgstr;
+ $state = 'msgid';
+ $msgid = "";
+ } 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;
+
+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_emptyhomes_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/make_emptyhomes_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
+
+ print OUTPO $buffer;
+
+ $buffer =~ s/FixMyStreet/Empty Homes Agency/g;
+ $buffer =~ s/\bproblem\b/empty property/g;
+ $buffer =~ s/\bProblem\b/Empty property/g;
+ $buffer =~ s/\bproblems\b/empty properties/g;
+ $buffer =~ s/\bProblems\b/Empty properties/g;
+ $buffer =~ s/a empty/an empty/g;
+ $buffer =~ s/fixed/returned to use/g;
+
+ $buffer =~ s/Recently put back into use empty properties/Recent empty properties put back into use/;
+ $buffer =~ s/New empty properties/New empty property reports/;
+ $buffer =~ s/Older empty properties/Older empty property reports/;
+ $buffer =~ s/Report, view, or discuss local empty properties/Report and view empty properties/;
+
+ $buffer =~ s/\(like graffiti.*\)/ /;
+ $buffer =~ s/(Please enter your full name).*? -/$1 -/;
+
+ $buffer =~ s/We send it to the council on your behalf/The details will be sent directly to the right person in the local council for them to take action/;
+ $buffer =~ s/To find out what local alerts we have for you/To find out what local alerts we have in your area, council or ward/;
+
+ if ($lookup{$buffer}) {
+ print OUTPO $lookup{$buffer};
+ } else {
+ die "Failed to find match with buffer: $buffer";
+ }
+
+ $buffer = "";
+ } elsif (!$start) {
+ print OUTPO $_;
+ } else {
+ $buffer .= $_;
+ }
+}
+