-
Notifications
You must be signed in to change notification settings - Fork 1
/
lwr-reg-compile
executable file
·57 lines (49 loc) · 1.07 KB
/
lwr-reg-compile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash -e
# Copyright 2012-2019 Michael Pozhidaev <[email protected]>
# Compiles the registry data to common text files
# lwr-reg-compile FLAVOR DEST_DIR
THIS="${0##*/}"
LANGS="en ro ru"
[ -z "$1" ] && echo "$THIS:no flavor given" >&2 && exit 1
[ -z "$2" ] && echo "$THIS:no destination directory given" >&2 && exit 1
FLAVOR="$1"
DEST_DIR="$2"
if ! [ -d base.$FLAVOR ]; then
echo "$THIS:no such flavor:$FLAVOR" >&2
exit 1
fi
process-file()
{
if [ -r "$1/$2" ] && [ "$(cat "$1/$2" | wc -l)" -ge 1 ]; then
echo "FILE $2"
cat "$1/$2"
fi
}
process-dir()
{
cd $1
find -type d | while read l; do
if [ "$l" != . ]; then
echo "DIR ${l#./}"
process-file "$l" strings.txt
process-file "$l" integers.txt
process-file "$l" booleans.txt
fi
done
cd ..
}
(
for i in base base.$FLAVOR; do
process-dir $i
done
) > "$DEST_DIR/registry.dat"
for i in $LANGS; do
(
if [ -d "i18n.$i" ]; then
process-dir "i18n.$i"
fi
if [ -d "i18n.$i.$FLAVOR" ]; then
process-dir "i18n.$i.$FLAVOR"
fi
) > "$DEST_DIR/registry.$i.dat"
done