-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtranslate.sh
executable file
·66 lines (51 loc) · 1.8 KB
/
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
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
64
#!/usr/bin/env bash
set -e
# Translate lightning-dart
pub --version
## (0) -- clean directories
if [ -d tool/translation ]; then
rm -rf tool/translation
fi
mkdir tool/translation
if [ -d lib/intl ]; then
rm -rf lib/intl
fi
mkdir lib/intl
# absolute path
TARGET=/Users/jorg/Documents/BizPlatform/lightning/lightning-dart
DIR=${TARGET}/tool/translation
## (1a) -- create cmd file
# intl/bin/extract_to_arb
echo "pub run intl_translation:extract_to_arb --output-dir=$DIR lib/lightning_dart " > xx
# local lib
find lib -type f -name *.dart -exec echo "{}" >> xx \;
tr '\n' ' ' < xx > translate_to_arb.sh
rm xx
## (1b) -- create arb file to be translated
# https://github.com/dart-lang/intl/blob/master/bin/extract_to_arb.dart
sh translate_to_arb.sh
echo "(1) ---- arb generated"
ls -lh tool/translation/*.arb
## (2) -- translate arb files
# in ../bin/trl_arb.dart
pub run lightning:trl_arb $DIR de
pub run lightning:trl_arb $DIR fr
pub run lightning:trl_arb $DIR es
echo "(2) ---- arb translated"
ls -lh tool/translation
## (3a) -- create cmd file
#echo "pub run intl:generate_from_arb --output-dir=lib/intl " > yy
echo "pub run intl_translation:generate_from_arb --output-dir=lib/intl --generated-file-prefix=ldart_ " > yy
find lib -type f -name *.dart -exec echo "{}" >> yy \;
# translated arb file names can only have _locale (no other _)
# echo " tool/translation/messages_de.arb tool/translation/messages_fr.arb" >> yy
find tool/translation -type f -name messages*.arb -exec echo "{}" >> yy \;
tr '\n' ' ' < yy > translate_from_arb.sh
rm yy
## (3b) -- create dart files
# https://github.com/dart-lang/intl/blob/master/bin/generate_from_arb.dart
sh translate_from_arb.sh
echo "(3) ---- intl generated"
ls -lh lib/intl
# base-messages_all.dart -> library messages_all
# base-messages_de.dart -> library messages_de;