From 15b173569d883bd8f0bcf0d72b1f98941c89ced2 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 26 Feb 2018 11:49:15 +0100 Subject: [PATCH] Zanata integration (https://trad.framasoft.org) 1. Install zanata-cli on your computer (https://zanata.readthedocs.io/en/latest/client/installation/linux-installation/) 2. Configure zanata-cli (https://zanata.readthedocs.io/en/latest/client/configuration/) 3. Do your stuff, add your new strings to locale/en.json only 4. Push the new locales: make push-locales 5. Translate on https://trad.framasoft.org 6. Pull the new locales: make pull-locales (requires the Perl module JSON, provided by libjson-perl on Debian) 7. Commit and enjoy --- .gitignore | 1 + .po2json.sh | 7 +++++++ .renest_json.pl | 26 ++++++++++++++++++++++++++ Makefile | 10 ++++++++++ po/.gitignore | 2 ++ po2json.php | 15 --------------- zanata.xml | 9 +++++++++ 7 files changed, 55 insertions(+), 15 deletions(-) create mode 100755 .po2json.sh create mode 100755 .renest_json.pl create mode 100644 Makefile create mode 100644 po/.gitignore delete mode 100644 po2json.php create mode 100644 zanata.xml diff --git a/.gitignore b/.gitignore index 4475c3c..69538d1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ vendor cache/ tpl_c/ .php_cs.cache +.zanata-cache/ # Temp files *~ diff --git a/.po2json.sh b/.po2json.sh new file mode 100755 index 0000000..4b090d9 --- /dev/null +++ b/.po2json.sh @@ -0,0 +1,7 @@ +#!/bin/bash +for i in po/*.po +do + j=$(echo $i | cut -d '.' -f 1 | cut -d '/' -f 2) + po2json -i $i -t locale/en.json --progress none | ./.renest_json.pl > po/$j.json + mv po/$j.json locale/$j.json +done diff --git a/.renest_json.pl b/.renest_json.pl new file mode 100755 index 0000000..3c44c38 --- /dev/null +++ b/.renest_json.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use JSON; +#use Hash::Merge::Simple qw(merge); + +my $json = JSON->new->utf8->space_before(0)->space_after(1)->indent(4)->canonical(1); + +my $new_json = {}; +my $old_json = ''; + +while (defined(my $line = )) { + $old_json .= $line; +} + +$old_json = decode_json($old_json); +for my $key (keys %{$old_json}) { + $key =~ m/^([^.]*)\.(.*)$/; + my $real_key = $1; + my $trad_key = $2; + + $new_json->{$real_key}->{$trad_key} = $old_json->{$key} if $old_json->{$key}; +} + +print $json->encode($new_json); diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..08696d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +push-locales: + json2po -P -i locale/en.json -t locale/en.json -o po/framadate.pot + zanata-cli -q -B push + +pull-locales: + zanata-cli -q -B pull + ./.po2json.sh + +stats-locales: + zanata-cli -q stats diff --git a/po/.gitignore b/po/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/po/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/po2json.php b/po2json.php deleted file mode 100644 index 07b77b7..0000000 --- a/po2json.php +++ /dev/null @@ -1,15 +0,0 @@ - - - - - -
convert($po);
-print_r($json);
-?>
- diff --git a/zanata.xml b/zanata.xml new file mode 100644 index 0000000..7bea509 --- /dev/null +++ b/zanata.xml @@ -0,0 +1,9 @@ + + + https://trad.framasoft.org/zanata/ + framadate + master + gettext + po + po +