~ubuntu-core-doc/ubuntu-docs/maverick

« back to all changes in this revision

Viewing changes to generic/translate.sh

  • Committer: Matthew East
  • Date: 2008-04-03 21:36:44 UTC
  • Revision ID: mdke@ubuntu.com-20080403213644-f1raxxlwe4ng37s6
Smashing up the directory to create new structure discussed on mailing list.
Nothing works.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
####################################################################################           
4
 
# Copyright (C) 2005-2006 Ubuntu Documentation Project (ubuntu-doc@lists.ubuntu.com)
5
 
#    This program is free software; you can redistribute it and/or modify
6
 
#    it under the terms of the GNU General Public License as published by
7
 
#    the Free Software Foundation; either version 2 of the License, or
8
 
#    (at your option) any later version. 
9
 
#
10
 
#    This program is distributed in the hope that it will be useful,
11
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
#    GNU General Public License for more details.
14
 
#
15
 
#    You should have received a copy of the GNU General Public License
16
 
#    along with this program; if not, write to the Free Software
17
 
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
#    On Debian based systems a copy of the GPL can be found 
19
 
#    at /usr/share/common-licenses/GPL
20
 
####################################################################################
21
 
 
22
 
# This script is for generating XML documents from po files downloaded from Launchpad
23
 
# Put your freshly downloaded po files into the po folder under each document, then run:
24
 
#
25
 
# $ translate.sh
26
 
#
27
 
# Optional parameters:
28
 
#       -d<documentname>
29
 
#       -l<language>
30
 
#
31
 
 
32
 
translate () {
33
 
        y=$(basename ${1} .po)
34
 
        echo " ${y}"
35
 
        mkdir -p ${y}
36
 
        for i in C/*xml; do
37
 
                j=$(basename ${i} C/)
38
 
                echo ${j}
39
 
                k=$(basename ${j} .xml)
40
 
                echo ${k}
41
 
                xml2po -e -p po/${y}.po C/${j} >${y}/${j}
42
 
        done
43
 
        if [ -e C/${document}-C.omf ]; then
44
 
                echo "  Generating omf file for ${document}"
45
 
            xml2po -e -p ${1} C/${document}-C.omf >${y}/${document}-${y}.omf
46
 
            sed -i -e s@\"C\"@\"${y}\"@g -e s@C/@${y}/@g ${y}/${document}-${y}.omf
47
 
        fi
48
 
        ../../validate.sh ${y}/${document}.xml
49
 
        bzr add -q ${y}
50
 
}
51
 
 
52
 
choose_language () {
53
 
        echo "Entering ${1}"
54
 
        cd ${1}
55
 
        if [ ${2} ]; then
56
 
                translate "po/${2}.po"
57
 
        else
58
 
                for x in po/*; do
59
 
                        translate ${x}
60
 
                done
61
 
        fi
62
 
        rm .xml2po.mo
63
 
        cd ..
64
 
}
65
 
 
66
 
while getopts "d:l:" Option
67
 
do
68
 
        case ${Option} in
69
 
                d) document=${OPTARG};;
70
 
                l) lang=${OPTARG};;
71
 
                *) echo "Please specify an argument.";;
72
 
        esac
73
 
done
74
 
 
75
 
if [ ${document} ]; then
76
 
        choose_language ${document} ${lang}
77
 
else
78
 
        for doc in serverguide
79
 
        do
80
 
                choose_language ${doc} ${lang}
81
 
        done
82
 
fi
83