dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19029
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8140: (Translations) Minor adjustment to cleaning script.
------------------------------------------------------------
revno: 8140
committer: Jason P. Pickering <jason.p.pickering@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-09-19 14:53:42 +0000
message:
(Translations) Minor adjustment to cleaning script.
modified:
resources/util/clean_translations.sh
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'resources/util/clean_translations.sh'
--- resources/util/clean_translations.sh 2012-06-21 09:43:10 +0000
+++ resources/util/clean_translations.sh 2012-09-19 14:53:42 +0000
@@ -1,5 +1,4 @@
#!/bin/bash
-
isNotSet() {
if [[ ! ${!1} && ${!1-_} ]]
then
@@ -8,7 +7,6 @@
}
-
if [[ $# -lt 1 ]]; then
echo "Usage: $0 original-properties-file translation-properties-file"
exit 1
@@ -18,24 +16,37 @@
declare -A array2
PROP_FILE=$2
+grep -Ev '^#' $1 | sed '/^\r/d' | grep -Ev '^$'| sort > tmpfile1
+grep -Ev '^#' $2 | sed '/^\r/d' | grep -Ev '^$'| sort > tmpfile2
+
while IFS='=' read -r key val; do
[[ $key = '#'* ]] && continue
- array1["$key"]="$val"
-done < $1
+ array1["$key"]="$val"
+done < tmpfile1
while IFS='=' read -r key val; do
[[ $key = '#'* ]] && continue
array2["$key"]="$val"
-done < $2
+done < tmpfile2
-echo "" > $2
+echo -n "" > $2
for key in "${!array1[@]}"; do
isNotSet array2[${key}]
-if [ $? -ne 1 ]
-then
- echo "$key=${array2[$key]}" >> ${PROP_FILE};
+
+if [ $? -ne 1 ];then
+
+value2=${array2[$key]}
+value1=${array1[$key]}
+
+if [[ *"$value1"* != *"$value2"* ]];then
+echo "$key=${array2[$key]}" >> ${PROP_FILE};
+fi
fi
done
+
+rm tmpfile1
+rm tmpfile2
+