forked from elementary/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepush.sh
executable file
·52 lines (40 loc) · 1.22 KB
/
prepush.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
#!/bin/bash
extract_translations () {
filename="$1"
pagename=$(echo "$filename" | sed 's/\.php$//' | sed 's/\.md$//')
output_file="lang/en/$pagename.json"
output_dirname=`dirname "$output_file"`
# Ignore some files
if [[ $pagename == "router" ]] ; then
return
fi
echo "Extracting: $pagename -> $output_file"
# Create dirname if it doesn't exist
if [ ! -d "$output_dirname" ] ; then
mkdir -p "$output_dirname"
fi
# Run l10n-extract.php
php -f backend/extract-l10n.php "$pagename" 2>>/dev/null > "$output_file"
# Add file to .tx/config
escaped_pagename=$(echo "$pagename" | sed 's/\//_/g')
if ! grep -F -q "[elementary-mvp.$escaped_pagename]" .tx/config; then
echo "Adding $pagename to .tx/config"
tx set -t KEYVALUEJSON --auto-local -r "elementary-mvp.$escaped_pagename" "lang/<lang>/$pagename.json" --source-lang en --execute
fi
}
# Cleanup
mkdir -p lang/en
rm -rf lang/en/*
echo "Extracting translations..."
# Extract layout
extract_translations "layout"
# Extract PHP files
for file in *.php; do
extract_translations "$file"
done
# Extract docs
for file in $(find docs -name '*.md'); do
extract_translations "$file"
done
echo "Done! You can now push source files on Transifex by running:"
echo "tx push -s"