[go: up one dir, main page]

File: extract-json

package info (click to toggle)
uranium 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,876 kB
  • sloc: python: 22,349; sh: 111; makefile: 11
file content (42 lines) | stat: -rwxr-xr-x 1,067 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/bash

# Extract strings from a list of JSON files.
#
# This script will extract strings from all JSON files in the directory
# passed as first argument. The second argument is the destination
# directory for the extracted message file.
#
# This script uses createjsoncontext to generate the actual message file
# from the JSON file.
#
# This script is based on handle_json_files.sh from KDE's translation
# scripts.
# handle_json_files.sh is copyright 2014 Burkhard Lück <lueck@hube-lueck.de>
scriptdir=$(dirname $0)

extract() {
    basedir=$1
    dest=$2
    file=$3

    python3 $scriptdir/createjsoncontext.py $file $basedir json.$$.tmp
    if test $? -eq 1; then
        return
    fi

    echo "Extracted messages from $file"

    msguniq --to-code=UTF-8 -o json.$$ json.$$.tmp
    if test -f json.$$; then
        destfile="$dest/$(basename $file).pot"
        mv json.$$ $destfile
    fi
    rm -f json.$$ json.$$.tmp
}

dir=$1; shift
dest=$1; shift

for file in $(find -L "$dir" -name *.json | grep -v 'tests'); do
    extract $dir $dest $file
done