File: lang.sh

package info (click to toggle)
caveexpress 2.4%2Bgit20160609-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 48,824 kB
  • sloc: cpp: 66,239; ansic: 1,135; sh: 471; xml: 186; python: 74; makefile: 20
file content (44 lines) | stat: -rwxr-xr-x 804 bytes parent folder | download | duplicates (5)
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
43
44
#!/bin/bash

DIR=$(dirname $(readlink -f $0))
cd $DIR/../..

LANG=${1:-de}
APPNAME=${2:-caveexpress}

grep -PohR 'tr\("\K[^"]*' src/modules src/${APPNAME} | sort | uniq | awk -v "app=${APPNAME}" -v "lang=${LANG}" '
BEGIN {
	old_FS = FS
	FS     = "\\|"
	status = 0
	file   = "base/" app "/lang/" lang ".lang"
	source = ""

	while (getline) {
		msgid = $1
		exists = 0
		input  = "cat " file
		t      = ""
		while (input | getline t) {
			split(t, msg, "\\|")
			if ( msg[1] != msgid ) {
				continue
			}
			if ( msg[2] != "" ) {
				print msg[1] "|" msg[2]
				exists = 1
			}
			break
		}
		close(input)
		if ( exists == 1 )
			continue

		print $1"|"$1
	}

	FS = old_FS

	exit status
}' > base/${APPNAME}/lang/${LANG}.lang.tmp
mv base/${APPNAME}/lang/${LANG}.lang.tmp base/${APPNAME}/lang/${LANG}.lang