aboutsummaryrefslogtreecommitdiffstats
path: root/bin/localise_templates
diff options
context:
space:
mode:
Diffstat (limited to 'bin/localise_templates')
-rw-r--r--bin/localise_templates36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/localise_templates b/bin/localise_templates
new file mode 100644
index 0000000..372535b
--- /dev/null
+++ b/bin/localise_templates
@@ -0,0 +1,36 @@
+#!/bin/env perl
+
+use strict;
+use warnings;
+use Template;
+use mySociety::Locale;
+
+mySociety::Locale::negotiate_language('de-ch,German,de_CH');
+mySociety::Locale::gettext_domain('ZurichMobileApp');
+mySociety::Locale::change('de-ch');
+
+sub loc {
+ my @args = @_;
+ return _(@args);
+}
+
+sub tprintf {
+ my ( $format, @args ) = @_;
+ @args = @{$args[0]} if ref $args[0] eq 'ARRAY';
+ return sprintf $format, @args;
+}
+
+my $t = Template->new({
+ INCLUDE_PATH => 'templates',
+ OUTPUT_PATH => 'compiled'
+});
+
+my $vars = {
+ loc => \&loc,
+ tprintf => \&tprintf,
+};
+
+for my $file ( glob('templates/*') ) {
+ $file =~ s%templates/%%;
+ $t->process( $file, $vars, $file ) or warn $t->error;
+}