My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
#
#Wrapper for xml2po for android and launchpad: Import .xml's from .po's, or export/update .po's from string.xml's. Provide a string with value "translator-credits" for Launchpad.
#
# Copyright (C) 2009 pjv
#
# This file is part of OpenIntents Androidxml2po.
#
# OpenIntents Androidxml2po is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenIntents Androidxml2po is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenIntents Androidxml2po. If not, see <http://www.gnu.org/licenses/>.
#
#

#Set the languages here (long version is the android resource append string).
short_lang=("nl" "de" "fr") #do not include template language ("en" usually).
long_lang=("nl_rNL" "de" "fr") #do not include template language ("en" usually).
#Change the dirs where the files are located.
launchpad_po_files_dir="translations"
launchpad_pot_file_dir="translations"
android_xml_files_res_dir="res/values"
#Change the typical filenames.
launchpad_po_filename="fortune"
android_xml_filename="strings"
#Location of xml2po
xml2po="xml2po"

function import_po2xml
{
for (( i=0 ; i<${#short_lang[*]} ; i=i+1 )) ;
do
echo "Importing .xml from .po for "${short_lang[i]}""
mkdir -p "${android_xml_files_res_dir}"-"${long_lang[i]}"
${xml2po} -a -l "${short_lang[i]}" -p "${launchpad_po_files_dir}"/"${launchpad_po_filename}"-"${short_lang[i]}".po "${android_xml_files_res_dir}"/"${android_xml_filename}".xml > "${android_xml_files_res_dir}"-"${long_lang[i]}"/"${android_xml_filename}".xml
done
}

function export_xml2po
{
echo "Exporting .xml to .pot"
${xml2po} -a -l "${short_lang[i]}" -o "${launchpad_pot_file_dir}"/"${launchpad_po_filename}".pot "${android_xml_files_res_dir}"/"${android_xml_filename}".xml

for (( i=0 ; i<${#short_lang[*]} ; i=i+1 )) ;
do
if [ -e "${launchpad_po_files_dir}"/"${launchpad_po_filename}"-"${short_lang[i]}".po ] ; then
echo "Exporting .xml to updated .po for "${short_lang[i]}""
echo "Making temporary folder: .tmp."${launchpad_po_files_dir}""
mkdir -p .tmp."${launchpad_po_files_dir}"
if [ -e "${android_xml_files_res_dir}"-"${long_lang[i]}"/"${android_xml_filename}".xml ] ; then
${xml2po} -a -u "${launchpad_po_files_dir}"/"${launchpad_po_filename}"-"${short_lang[i]}".po "${android_xml_files_res_dir}"/"${android_xml_filename}".xml
else
${xml2po} -a -u "${launchpad_po_files_dir}"/"${launchpad_po_filename}"-"${short_lang[i]}".po "${android_xml_files_res_dir}"/"${android_xml_filename}".xml
fi
fi
done
}

function usage
{
echo "Wrapper for xml2po for android and launchpad."
echo "Usage: androidxml2po -i Import .xml's from .po's. Updates the .xml's."
echo " androidxml2po -e Export/update .po's from string.xml's. Overwrites the .pot and merges the .po's."
echo "Set variables correctly inside. Provide a string with value "translator-credits" for Launchpad."
echo ""
echo "Copyright 2009 by pjv. Licensed under GPLv3."
}

###Main
while [ "$1" != "" ]; do
case $1 in
-i | --po2xml | --import ) shift
import_po2xml
exit
;;
-e | --xml2po | --export ) export_xml2po
exit
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
usage

Change log

r1987 by ezelspinguin on Mar 13, 2009   Diff
Androidxml2po: made license more explicit
Go to: 
Sign in to write a code review

Older revisions

r1815 by ezelspinguin on Jan 21, 2009   Diff
Androidxml2po: Updates to make
documentation less restrictive. Fixed
bug of "-r" option being rejected.
r1811 by ezelspinguin on Jan 20, 2009   Diff
tools/androidxml2po: Added
androidxml2po.bash.

All revisions of this file

File info

Size: 3964 bytes, 95 lines
Powered by Google Project Hosting