Dotclear

source: locales/po_update.sh @ 1046:24b905e118ac

Revision 1046:24b905e118ac, 3.9 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Add daInstaller plugin to the distribution, closes #1359

  • Property exe set to *
Line 
1#!/bin/sh
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13# Usage (from l10n-plugins root)
14# po_update.sh <dotclear-root> [<lang>]
15
16export LANG=C
17
18XGETTEXT=xgettext
19MSGMERGE=msgmerge
20
21PLUGINS="
22aboutConfig
23akismet
24antispam
25attachments
26blogroll
27blowupConfig
28daInstaller
29fairTrackbacks
30importExport
31maintenance
32pages
33pings
34simpleMenu
35tags
36themeEditor
37userPref
38widgets
39"
40
41PO_LANG=$1
42PO_MODULE=$2
43
44if [ ! -d ./inc/core ]; then
45     echo "You are not on Dotclear root directory"
46     exit 1
47fi
48
49if [ ! -d locales/_pot ]; then
50     echo "Template not found."
51     exit 1
52fi
53
54extract_strings()
55{
56     $XGETTEXT \
57     -f- \
58     --sort-by-file \
59     -L PHP -k__ \
60     --no-wrap \
61     --foreign-user \
62     --from-code=UTF-8 \
63     "$@"
64}
65
66extract_html_strings()
67{
68     tee -
69     
70     $XGETTEXT \
71     - \
72     --sort-by-file \
73     -L PHP -k__ \
74     --no-wrap \
75     --foreign-user \
76     --from-code=UTF-8 \
77     "$@"
78}
79update_po()
80{
81     po_file=$1
82     pot_file=$2
83     po_dir=`dirname $1`
84     po_tmp=$po_dir/tmp.po~
85     
86     if [ ! -d $po_dir ]; then
87          mkdir $po_dir
88     fi
89     
90     if [ ! -f $po_file ]; then
91          cp $pot_file $po_file
92          perl -pi -e "s|; charset=CHARSET|; charset=UTF-8|sgi;" $po_file $po_file
93     fi
94     
95     $MSGMERGE --no-location --no-wrap -o $po_tmp $po_file $pot_file
96     mv $po_tmp $po_file
97}
98
99if [ -z "$PO_MODULE" ]; then
100     #
101     # Create po template files
102     #
103     echo "Building main PO template..."
104     find ./admin ./inc -name '*.php' -not -regex '.*/inc/public/.*' -print | \
105          extract_strings \
106          --package-name="Dotclear 2" \
107          -o locales/_pot/main.pot \
108          -x locales/_pot/date.pot
109     
110     echo "DONE"
111     
112     # plugins.pot
113     echo "Building plugins PO template..."
114     for p in $PLUGINS; do
115          find ./plugins/$p -name '*.php' -print
116     done | \
117          extract_strings \
118          --package-name="Dotclear 2" \
119          -o locales/_pot/plugins.pot \
120          -x locales/_pot/date.pot \
121          -x locales/_pot/main.pot
122     
123     echo "DONE"
124     
125     #
126     # Update locales/<lang> if needed
127     #
128     if [ -z "$PO_LANG" ]; then
129          exit 0;
130     fi
131     
132     # Init locale if not present
133     if [ ! -d locales/$PO_LANG ]; then
134          mkdir -p locales/$PO_LANG/help
135         
136          # Base help files
137          for i in locales/en/help/*.html; do
138               cp $i locales/$PO_LANG/help/core_`basename $i`
139          done
140          for i in $PLUGINS; do
141               if [ -f plugins/$i/help.html ]; then
142                    cp plugins/$i/help.html locales/$PO_LANG/help/$i.html
143               fi
144          done
145     fi
146     
147     # update main.po
148     echo "Updating <$PO_LANG> po files..."
149     update_po ./locales/$PO_LANG/main.po ./locales/_pot/main.pot
150     update_po ./locales/$PO_LANG/plugins.po ./locales/_pot/plugins.pot
151     update_po ./locales/$PO_LANG/public.po ./locales/_pot/public.pot
152     update_po ./locales/$PO_LANG/date.po ./locales/_pot/date.pot
153else
154     #
155     # Plugin language update
156     #
157     
158     if [ ! -d $PO_MODULE ]; then
159          echo "Module $PO_MODULE does not exist"
160          exit 1
161     fi
162     echo "Module $PO_MODULE language update"
163     
164     
165     #
166     # Building po template file
167     #
168     if [ ! -d $PO_MODULE/locales/_pot ]; then
169          mkdir -p $PO_MODULE/locales/_pot
170     fi
171     echo "Building main PO template..."
172     echo '<?php' >$PO_MODULE/__html_tpl_dummy.php
173     find $PO_MODULE -name '*.html' -exec grep -o '{{tpl:lang [^}]*}}' {} \; | sed 's/{{tpl:lang \(.*\)}}$/__\("\1")/' | sort -u \
174          >> $PO_MODULE/__html_tpl_dummy.php
175     sed -i "" 's/\$/\\\$/g' $PO_MODULE/__html_tpl_dummy.php
176     
177     find $PO_MODULE -name '*.php' -print | \
178          extract_strings \
179          --package-name="Dotclear 2 `basename $PO_MODULE` module" \
180          -o $PO_MODULE/locales/_pot/main.pot \
181          -x locales/_pot/date.pot -x locales/_pot/main.pot -x locales/_pot/public.pot -x locales/_pot/plugins.pot
182     
183     rm -f $PO_MODULE/__html_tpl_dummy.php
184     
185     echo "DONE"
186     
187     #
188     # Update locale/<lang>
189     #
190     if [ ! -d $PO_MODULE/locales/$PO_LANG ]; then
191          mkdir -p $PO_MODULE/locales/$PO_LANG
192     fi
193     echo "Updating module <$PO_MODULE> main <$PO_LANG> po file... "
194     update_po $PO_MODULE/locales/$PO_LANG/main.po $PO_MODULE/locales/_pot/main.pot
195fi
Note: See TracBrowser for help on using the repository browser.

Sites map