scripts: fix translations

Translations with a comma in the key are rewritten to be on a single
line.

But this failed when the comma was just preceded by a dot (like in
`etc.,`).

Fix the script so that it works even in those cases.
This commit is contained in:
Pierre de La Morinerie 2019-04-17 10:49:10 +00:00
parent 80336b431e
commit d110ee558f
10 changed files with 24 additions and 19 deletions

View file

@ -4,7 +4,12 @@ po2json -i po/en.po -t locale/en.json --progress none -o po/default.json
for i in po/*.po
do
j=$(echo $i | cut -d '.' -f 1 | cut -d '/' -f 2)
vim -E -c "while search('^\\(#: \\..*\\)\\(\\n\\_^#: \\([^.].*\\)\\)\\+') | execute 'normal J' | s/ #: /,/ | endwhile" -c 'x' -- $i
# When there is a comma in a key, Zanata replaces it by a newline. And po2json doesn't like this.
# Edit the po file, to restore split key names on a single line again.
vim -E -c "while search('^\\(#: \\..*\\)\\(\\n\\_^#: \\([^.].*\\)\\)\\+') | s/\n#: /,/ | endwhile" -c 'x' -- $i
# Convert the po file to json
po2json -i $i -t po/default.json --progress none | scripts/renest_json.pl > po/$j.json
mv po/$j.json locale/
done