Modified the generateTranslationDiffs.sh file, runs ~34% faster
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Append translation differences on the end of all files. Developers should run this script
|
# Append translation differences on the end of all files. Developers should run this script
|
||||||
# after changing default, so that translators can easily see what items need to be translated.
|
# after changing default, so that translators can easily see what items need to be translated.
|
||||||
@@ -15,36 +15,34 @@ if [[ $? != 0 ]]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#First thing, we want to strip default of any !s and duplicates.
|
#First thing, we want to strip default of any "!" and duplicates.
|
||||||
cat "default" | grep -v '^!' | sort -Vu > "$TEMP"
|
grep -v '^!' default | sort -Vu > "$TEMP"
|
||||||
mv "$TEMP" "default"
|
mv "$TEMP" "default"
|
||||||
|
|
||||||
echo "Generating differences... this may take a few minutes."
|
echo "Generating differences... this may take a few minutes."
|
||||||
|
|
||||||
find . |
|
#Find all language files, excluding non-language files
|
||||||
grep -v 'default' |
|
find . -not -iname "default" -not -iname "LICENSE" -not -iname "README" -not -iname "*.sh" -not -iname ".*" -not -iname "$TEMP" |
|
||||||
grep -v 'README' |
|
|
||||||
grep -v 'LICENSE' |
|
|
||||||
grep -v 'generateDiffs.sh' |
|
|
||||||
grep -v "$TEMP" |
|
|
||||||
grep -v '^.$' |
|
|
||||||
|
|
||||||
|
#for every found language file X
|
||||||
while read X; do
|
while read X; do
|
||||||
echo "Working on differences for $X"
|
echo "Working on differences for $X"
|
||||||
|
|
||||||
#Start by copying the existing file to a temporary one, after sorting and removing all
|
#Start by copying the existing file to a temporary one, after sorting and removing all "!"
|
||||||
#previous differences
|
grep -v '^!' "$X" | sort -Vu > "$TEMP"
|
||||||
cat "$X" | grep -v '^!' | sort -Vu > "$TEMP"
|
|
||||||
|
|
||||||
echo -e "\n\n!!!!!!!!!!!!!!!!!!!!!!!!!\n! Untranslated keys follow; remove the ! prefix after an entry is translated.\n!!!!!!!!!!!!!!!!!!!!!!!!!\n\n" >> "$TEMP"
|
echo -e "\n\n!!!!!!!!!!!!!!!!!!!!!!!!!\n! Untranslated keys follow; remove the ! prefix after an entry is translated.\n!!!!!!!!!!!!!!!!!!!!!!!!!\n\n" >> "$TEMP"
|
||||||
|
|
||||||
cat 'default' | grep -v '^#' | while read LINE; do
|
#find every line that is not a comment
|
||||||
KEY=`echo "$LINE" | cut -f 1 -d ';'`
|
grep -v '^#' default | while read LINE
|
||||||
grep -q "^$KEY" "$X";
|
do
|
||||||
if [[ $? != 0 ]]; then
|
KEY=${LINE%%;*}
|
||||||
echo "!$LINE" >> "$TEMP"
|
grep -q "^$KEY" "$X"
|
||||||
fi
|
if [[ $? != 0 ]]
|
||||||
done
|
then
|
||||||
|
echo '!'"${LINE}" >> "$TEMP"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
#Replace the old file with the new one, with a section at the end for differences.
|
#Replace the old file with the new one, with a section at the end for differences.
|
||||||
mv "$TEMP" "$X"
|
mv "$TEMP" "$X"
|
||||||
|
Reference in New Issue
Block a user