diff --git a/.gitignore b/.gitignore index 4475c3c7a5502b712f0415061bf23119c3a358e0..69538d1e4826a5d60138f93272f3ed31843a1250 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 0000000000000000000000000000000000000000..4b090d9964cd638942ee7f66b893b45f2b2c5cc1 --- /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 0000000000000000000000000000000000000000..3c44c3870168329ee34b5dc0c18f430e86d20c4e --- /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 = <STDIN>)) { + $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 0000000000000000000000000000000000000000..08696d2c4d53e2811d94d4ae10053a437ca8dcf5 --- /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 0000000000000000000000000000000000000000..d6b7ef32c8478a48c3994dcadc86837f4371184d --- /dev/null +++ b/po/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/po2json.php b/po2json.php deleted file mode 100644 index 07b77b78622ce32f9300c937ce87c14e574d76b6..0000000000000000000000000000000000000000 --- a/po2json.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -include_once __DIR__ . '/app/inc/init.php'; -?> -<html> -<head> - <meta charset="utf-8"/> -</head> -<body><pre><?php -$lang = 'fr_FR'; -$po = file_get_contents(__DIR__ . '/locale/' . $lang . '/LC_MESSAGES/Studs.po'); -$converter = new \o80\convert\Po2JsonConverter(); -$json = $converter->convert($po); -print_r($json); -?></pre></body> -</html> diff --git a/zanata.xml b/zanata.xml new file mode 100644 index 0000000000000000000000000000000000000000..7bea50948fa5a25407f934ce58d700b75f90dc0d --- /dev/null +++ b/zanata.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<config xmlns="http://zanata.org/namespace/config/"> + <url>https://trad.framasoft.org/zanata/</url> + <project>framadate</project> + <project-version>master</project-version> + <project-type>gettext</project-type> + <src-dir>po</src-dir> + <trans-dir>po</trans-dir> +</config>