Author: keichwa Date: 2015-07-23 13:41:49 +0200 (Thu, 23 Jul 2015) New Revision: 92157 Added: trunk/lcn/50-tools/lcn-make-json.sh Log: Summary: new Added: trunk/lcn/50-tools/lcn-make-json.sh =================================================================== --- trunk/lcn/50-tools/lcn-make-json.sh (rev 0) +++ trunk/lcn/50-tools/lcn-make-json.sh 2015-07-23 11:41:49 UTC (rev 92157) @@ -0,0 +1,74 @@ +#!/bin/bash + +export LC_ALL=C + +TEMP=$(getopt -o chi:lm:j:t \ + --long commit,help,lang,langs,languages,message:,msg:,json:,json-template:,tar,threshold: \ + -n "$0" -- "$@") +# Note the quotes around `$TEMP': they are essential! +eval set -- "$TEMP" + +usage="Usage: $0 [OPTION]... -l [LANG]... +Create json files from po translation files + + -c, --commit Commit created json files + -m, --msg, --messages \"MSG\" The commit message + -i, --threshold N Only create files where translation completion is above + N percent (default: 50) + -j, --json, --json-template [JSONFILE] + json template file to use + -t, --tar Create tar + -l [LANG]..., --language [LANG]... + Create listed LANGuages only. This is the final option. + -h, --help Display this help and exit +" + +po2json=/usr/bin/po2json + +while true ; do + case "$1" in + -h|--help) echo "$usage"; exit ;; + -c|--commit) commit=yes; shift ;; + -l|--lang*) shift 2; langs="$@"; break;; + -m|--msg|--message) msg="$2"; shift 2 ;; + -i|--threshold) i="$2"; shift 2 ;; + -j|--json|--json-template) json=$2; shift 2 ;; + -t|--tar) tar=yes; shift ;; + -v|--verbose) verbose="-v"; echo=echo; shift ;; + --) shift ; break ;; + *) langs="$langs $1"; shift ;; +# *) echo "Internal error!" ; exit 1 ;; + esac +done + +langs=${langs-"?? ??_??"} #??@???? + +if [ -n "$json" ]; then + domain=${json#50-json/} + domain=${domain%\.json} + # echo $json + domain=${domain/\//} + json_template=50-json/$domain.json +fi + +[ -x $po2json ] || { + echo "$po2json missing; install translate toolkit!" + exit 1 +} + +# translation threshold (percentage) +[ -n "$i" ] || i=50 + +for l in $langs; do + if [ -f $l/po/$domain.$l.po ]; then + $po2json --threshold=$i -t $json_template $l/po/$domain.$l.po json/ + fi +done + +if [ -n "$tar" ]; then + tar cvjf $domain.tar.bz2 \ + --transform=s,json/$domain.,$domain/, \ + json/$domain.*.json +fi + +exit 0 Property changes on: trunk/lcn/50-tools/lcn-make-json.sh ___________________________________________________________________ Added: svn:executable + *