-
Notifications
You must be signed in to change notification settings - Fork 0
/
translate.sh
28 lines (22 loc) · 896 Bytes
/
translate.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
#!/bin/bash
LOCALES_FOLDER=app/public/locales
MISSING_FILE="$LOCALES_FOLDER/missing.txt"
MODULES=(google bing)
while IFS= read -r name; do
if [ -f "$LOCALES_FOLDER/$name/translation.json" ]; then
continue
fi
mkdir -p "$LOCALES_FOLDER/$name"
for mod in "${MODULES[@]}"; do
node_modules/@parvineyvazov/json-translator/bin/jsontt "$LOCALES_FOLDER/en/translation.json" --module $mod --from en --to $name --name translation -cl 1 -fb yes
if [ $? -eq 0 ]; then
mv "$LOCALES_FOLDER/en/translation.$name.json" "$LOCALES_FOLDER/$name/translation.json"
break;
fi
done
if [ ! -f "$LOCALES_FOLDER/$name/translation.json" ]; then
touch $MISSING_FILE
grep -qxF $name $MISSING_FILE || echo $name >> $MISSING_FILE
fi
done <"$LOCALES_FOLDER/locales.txt"
# https://translate.i18next.com/ for missing