Magellan Linux

Annotation of /tags/installer-simple-0_4_91_20160203_1/generate-po.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2354 - (hide annotations) (download) (as text)
Mon Jan 6 12:21:55 2014 UTC (10 years, 3 months ago) by niro
Original Path: trunk/installer-simple/generate-po.sh
File MIME type: application/x-sh
File size: 1908 byte(s)
-fixed whitespaces
1 niro 2350 #!/bin/bash
2    
3     method="$1"
4     script="$2"
5     domain="$3"
6     languages="de"
7     localedir="/usr/share/locale"
8    
9     usage()
10     {
11     echo "Usage: $0 [method] [shell script] {domain}"
12     echo "Known methods:"
13     echo " --create-pot - creates pot file from script"
14     echo " --append-pot - appends current pot file with script"
15     echo " --generate - generates pot and po files"
16     echo " --compile - compiles mo files"
17     echo
18     echo "Examples:"
19     echo " $0 --generate example.sh"
20     echo " $0 --compile example.sh"
21     echo
22     }
23    
24     create_pot()
25     {
26     local pot
27    
28     install -d locale
29     pot="locale/${domain}.pot"
30     bash --dump-po-strings "${script}" > "${pot}"
31     }
32    
33     append_pot()
34     {
35     local pot
36    
37     install -d locale
38     pot="locale/${domain}.pot"
39     bash --dump-po-strings "${script}" >> "${pot}"
40     }
41    
42     generate_po()
43     {
44     local lang
45     local po
46     local pot
47    
48     pot="locale/${domain}.pot"
49     if [ ! -f "${pot}" ]
50     then
51     echo "Error: ${pot} missing - run --create-pot or --append-pot"
52 niro 2354 exit 1
53 niro 2350 fi
54    
55     for lang in ${languages}
56     do
57     po="locale/${lang}/${domain}.po"
58     if [ -f "${po}" ]
59     then
60     echo "Updating lang '${lang}'"
61     msgmerge --quiet --no-fuzzy-matching --no-wrap --update "${po}" "${pot}"
62     else
63     echo "Processing lang '${lang}'"
64     install -d locale/"${lang}"
65     install -m0644 "${pot}" "${po}"
66     fi
67     done
68     }
69    
70     generate_mo()
71     {
72     local lang
73     local dir
74     local po
75    
76     for lang in ${languages}
77     do
78     echo "Compiling lang '${lang}'"
79     po="locale/${lang}/${domain}.po"
80     if [ ! -f "${po}" ]
81     then
82     echo "Error: ${po} missing - run --generate first"
83     exit 1
84     fi
85     dir="${DESTDIR}/${localedir}/${lang}/LC_MESSAGES"
86     install -d "${dir}"
87     msgfmt -o "${dir}"/"${domain}".mo "${po}"
88     done
89     }
90    
91     if [[ -z ${script} ]]
92     then
93     usage
94     echo "Error: Script missing"
95     exit 1
96     fi
97    
98     if [[ -z ${domain} ]]
99     then
100     domain="${script}"
101     fi
102    
103     case ${method} in
104     --create-pot) create_pot ;;
105     --append-pot) append_pot ;;
106     --generate) generate_po ;;
107     --compile) generate_mo ;;
108     *) usage ;;
109     esac

Properties

Name Value
svn:executable *