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
This commit is contained in:
Luc Didry 2018-02-26 11:49:15 +01:00
parent 87b89bc609
commit 15b173569d
7 changed files with 55 additions and 15 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ vendor
cache/
tpl_c/
.php_cs.cache
.zanata-cache/
# Temp files
*~

7
.po2json.sh Executable file
View File

@ -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

26
.renest_json.pl Executable file
View File

@ -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);

10
Makefile Normal file
View File

@ -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

2
po/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -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>

9
zanata.xml Normal file
View File

@ -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>