-
Notifications
You must be signed in to change notification settings - Fork 17
/
pull_and_clean_properties.sh
executable file
·63 lines (47 loc) · 1.68 KB
/
pull_and_clean_properties.sh
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
58
59
60
61
62
63
#!/bin/bash
# Check for pending changes
if ! git diff-index --quiet HEAD --; then
echo "Error: There are pending changes. Please commit or stash them before running the script."
exit 1
fi
# Function to process each .properties file
process_file() {
local file=$1
echo "Processing file: $file"
sed -i.bak -e 's/[[:space:]]*$//' -e 's/[[:space:]]*=[[:space:]]*/=/' "$file"
rm "${file}.bak"
echo "Processed file: $file"
}
export -f process_file
# Function to handle tx pull, rename, and delete operations
tx_operations() {
local lang=$1
local ext=$2
echo ">>>>>>>>>>>>>>>>>>>>>>> Pulling translations for $lang"
tx pull --force -l "$lang"
wait
find . -type f -name "*.$ext.properties" -delete
find . -type f -name "*.$lang.properties" -exec sh -c 'mv "$0" "${0%.'$lang'.properties}.'$ext'.properties"' {} \;
echo ">>>>>>>>>>>>>>>>>>>>>>> Finished processing $lang files."
}
# Perform git operations
echo "Checking out to main and pulling latest changes..."
git checkout main
git pull
echo "Checking out to transifex and pulling latest changes..."
git checkout transifex
git pull
echo "Merging transifex branch with main branch..."
git merge main
echo ">>>>>>>>>>>>>>>>>>>>>>> Pulling general translations..."
tx pull --force --all
wait
# Perform tx pull operations for specified languages
tx_operations "tr_TR" "tr"
tx_operations "pl_PL" "pl"
# Find all .properties files and process them
find . -type f -name "*.properties" -exec bash -c 'process_file "$0"' {} \;
# Delete all ca.properties and uk.properties files
find . -type f -name "*.ca.properties" -delete
find . -type f -name "*.uk.properties" -delete
echo ">>>>>>>>>>>>>>>>>>>>>>> Finished processing general files"