/
create-transifex-resources.sh
executable file
·95 lines (82 loc) · 2.5 KB
/
create-transifex-resources.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# This script is used to register InaSAFE translatable resources with Transifex
# http://transifex.com
#
# Note that this script updates or creates entries in .tx/config file
#
# Tim Sutton, March 2013
#
# Sphinx documentation first
#
LOCALES=`ls docs/i18n`
for ITEM in user-docs developer-docs tutorial-docs
do
for POFILE in `find docs/i18n/en/LC_MESSAGES/${ITEM}/ -type f -name '*.po'`
do
# get the po file replacing 'en' with '<lang>'
GENERICFILE=`echo $POFILE | sed 's/\/en\//\/<lang>\//g' | sed 's/\/\//\//g'`
echo $GENERICFILE
# Get the filename only part of the po file so we can use that
# name when registering the resource
BASE=`basename $GENERICFILE .po`
BASE=`echo $BASE | sed 's/_/-/g' | sed 's/ /-/g'`
RESOURCE=inasafe.${ITEM}-$BASE
# Register each po file as a transifex resource (an individual translatable file)
#set -x
tx set -t PO --auto-local -r $RESOURCE \
"$GENERICFILE" \
--source-lang en \
--execute
#set +x
# Now register the language translations for the localised po file against
# this resource.
for LOCALE in $LOCALES
do
LOCALEFILE=`echo $POFILE | sed "s/\/en\//\/$LOCALE\//g"`
tx set -r $RESOURCE -l $LOCALE "$LOCALEFILE"
done
# When we are done in this block we should have created a section in the
# .tx/config file that looks like this:
#
#
# [inasafe.user-docs-faq]
# file_filter = docs/i18n/<lang>/LC_MESSAGES/user-docs/faq.po
# source_file = docs/i18n/en/LC_MESSAGES/user-docs/faq.po
# source_lang = en
# trans.id = docs/i18n/id/LC_MESSAGES/user-docs/faq.po
# type = PO
done
done
#
# Now safe package
#
POFILE='safe/i18n/en/LC_MESSAGES/inasafe.po'
RESOURCE='safe/i18n/<lang>/LC_MESSAGES/inasafe.po'
tx set -t PO --auto-local -r inasafe.safe \
$RESOURCE \
--source safe/i18n/en/LC_MESSAGES/inasafe.po \
--source-lang en --execute
for LOCALE in $LOCALES
do
LOCALEFILE=`echo $POFILE | sed "s/\/en\//\/$LOCALE\//g"`
tx set -r $RESOURCE -l $LOCALE "$LOCALEFILE"
done
#
# Now safe_qgis package
#
TSFILE='safe_qgis/i18n/inasafe_en.ts'
RESOURCE='safe_qgis/i18n/inasafe_<lang>.ts'
tx set -t QT --auto-local -r inasafe.safe_qgis \
$RESOURCE \
--source-lang en \
--source $TSFILE \
--execute
for LOCALE in $LOCALES
do
LOCALEFILE=`echo $TSFILE | sed "s/\_en/\_$LOCALE/g"`
tx set -r $RESOURCE -l $LOCALE "$LOCALEFILE"
done
#Print out a listing of all registered resources
tx status
# Push all the resources to the tx server
tx push -s