This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 280
/
create_transifex_resources.sh
executable file
·81 lines (72 loc) · 2.56 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
#!/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 i18n`
# to be sure there are no pot files left
make springclean
#for ITEM in site
#do
for POFILE in `find i18n/en/LC_MESSAGES/${ITEM}/ -type f -name '*.po'`
do
# get the po file replacing 'en' with '<lang>' and removing doube // in path
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=`dirname $GENERICFILE`/`basename $GENERICFILE .po`
# removing i18n/<lang>/LC_MESSAGES
# replace _ in - in filenames
# replace empty spaces to -
# replace / in _
# replace . to _ (eg for release2.0 names)
# so we have for a file like
# site/about/my_screenshots/index.po
# we will get
# site_about_my-screenshots_index
BASE=`echo $BASE | sed 's,i18n.*LC_MESSAGES\/,,g' | sed 's,_,-,g' | sed 's, ,-,g' | sed 's,/,_,g' | sed 's,\.,-,g'`
# RESOURCE=qgis-website.${ITEM}-$BASE
RESOURCE=qgis-website.$BASE
#echo $RESOURCE
# Register each po file as a transifex resource (an individual translatable file)
#set -x
echo "Adding $POFILE (PO file) with --resource $RESOURCE, --file-filter $GENERICFILE"
./tx add \
--resource $RESOURCE \
--file-filter "$GENERICFILE"
--type PO \
$POFILE
echo "Config now reads"
cat .tx/config
#set +x
# Now register the language translations for the localised po file against
# this resource.
# for LOCALE in $LOCALES
# do
# if [ "$LOCALE" != "en" -a "$LOCALE" != "pot" ]; then
# LOCALEFILE=`echo $POFILE | sed "s/\/en\//\/$LOCALE\//g"`
# #echo "$LOCALEFILE"
# tx set -r $RESOURCE -l $LOCALE "$LOCALEFILE"
# fi
# done
# When we are done in this block we should have created a section in the
# .tx/config file that looks like this:
#
# [qgis-website.site_forusers_alldownloads]
# file_filter = i18n/<lang>/LC_MESSAGES/site/forusers/alldownloads.po
# source_file = i18n/en/LC_MESSAGES/site/forusers/alldownloads.po
# source_lang = en
# trans.nl = i18n/nl/LC_MESSAGES/site/forusers/alldownloads.po
# type = PO
done
#done
#Print out a listing of all registered resources
#tx status
# Push all the resources to the tx server
#tx push -s