forked from DeNA/PacketProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-properties
More file actions
executable file
·39 lines (32 loc) · 1.24 KB
/
update-properties
File metadata and controls
executable file
·39 lines (32 loc) · 1.24 KB
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
#!/bin/bash
function last_modified() {
if [ $(uname) == "Darwin" ]; then
timestamp=$(stat -f "%m" $1)
else
timestamp=$(stat -c %Y $1)
fi
echo $timestamp
}
cd src
tmp1=`mktemp`
tmp2=`mktemp`
ja_properties=main/resources/strings_ja.properties
ja_properties_ja_orig=`mktemp`
ja_properties_ja_new=`mktemp`
ja_properties_ja_merged=`mktemp`
ja_properties_ja_sorted=`mktemp`
grep -r -o -E 'I18nString.get\("[^"]*"' * | grep -o -E '".*"' | sed 's/"//g' | sed 's/ /_/g' | sed 's/=/_/g' | sed 's/:/\\:/g' | sed 's/(/\\(/g' | sed 's/)/\\)/g' > $tmp1
grep -r -o -E 'I18nString.get\("[^"]*"' * | grep -o -E '".*"' | sed 's/"//g' > $tmp2
cat $ja_properties | sort -b | sed 's/=/@@/g' | sed 's/@@/=/' > $ja_properties_ja_orig
paste -d = $tmp1 $tmp2 | sort -b | uniq > $ja_properties_ja_new
join -t = -a 1 -o "1.1 2.2" $ja_properties_ja_new $ja_properties_ja_orig > $ja_properties_ja_merged
join -t = -v 2 $ja_properties_ja_new $ja_properties_ja_orig >> $ja_properties_ja_merged
sort -b $ja_properties_ja_merged | sed 's/@@/=/g' > $ja_properties_ja_sorted
old=$(last_modified $ja_properties_ja_sorted)
vim $ja_properties_ja_sorted
new=$(last_modified $ja_properties_ja_sorted)
if [ $old -eq $new ]; then
echo "Abort"
else
cp $ja_properties_ja_sorted $ja_properties
fi