Skip to content

Commit ee72bab

Browse files
committed
feat(script): add shell script for running the google translation helper
1 parent 586a68e commit ee72bab

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.scripts/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Scripts
2+
3+
Useful scripts for the translation.
4+
5+
## From Google Translation
6+
7+
Translate all untranslated entries of the given .po file with Google Translate.
8+
9+
10+
```sh
11+
.scripts/google_translate.sh library/csv.po
12+
```

.scripts/google_translate.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
WORK_DIR=.scripts
4+
cd $WORK_DIR
5+
6+
source utils/install_poetry.sh
7+
8+
TEMP=tmp.po
9+
TARGET=../$1
10+
11+
poetry install -q
12+
poetry run bash -c "
13+
python google_translate/main.py $TARGET > $TEMP
14+
pomerge -t $TARGET -i $TEMP -o $TARGET
15+
"
16+
rm $TEMP

.scripts/utils/install_poetry.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if [[ ! -x "`which poetry 2>/dev/null`" ]]
2+
then
3+
read -p "You do not have poetry installed. Install now? (y/N)" choice
4+
case "$choice" in
5+
y|Y ) python -m pip install poetry;;
6+
n|N|* ) echo "Aborted"; exit 1 ;;
7+
esac
8+
fi

0 commit comments

Comments
 (0)