-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18n.sh
executable file
·41 lines (33 loc) · 1.04 KB
/
i18n.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
#!/bin/bash
Extract() {
echo extract untranslated messages...
goi18n extract -outdir ./internal/local/i18n
goi18n merge -outdir ./internal/local/i18n ./internal/local/i18n/active.*.toml
echo translate.*.toml with the messages to be translated.
}
Merge() {
echo merge translated files...
goi18n merge -outdir ./internal/local/i18n ./internal/local/i18n/active.*.toml ./internal/local/i18n/translate.*.toml
rm -f ./internal/local/i18n/translate.*.toml
echo merged and deleted translate.*.toml
}
if ! command -v goi18n &>/dev/null; then
echo "No goi18n tool found!"
echo "Please run the command: go install -v github.com/nicksnyder/go-i18n/v2/goi18n@latest"
exit 3
fi
echo 'Select the operation: '
PS3='Pick an option: '
options=("Extract untranslated messages" "Merge translated files")
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1)
Extract
break;;
2)
Merge
break;;
$(( ${#options[@]}+1 )) ) echo "$opt"; break;;
*) echo "Invalid option. Try another one."; continue;;
esac
done