Dotclear

source: build-tools/po_update.sh @ 3009:461a5ca8e825

Revision 3009:461a5ca8e825, 4.0 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Includes breadcrumb plugin to the distribution, fixes #1902

  • 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-2013 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
28breadcrumb
29dclegacy
30fairTrackbacks
31importExport
32maintenance
33pages
34pings
35simpleMenu
36tags
37themeEditor
38userPref
39widgets
40dcLegacyEditor
41dcCKEditor
42_fake_plugin
43"
44
45PO_LANG=$1
46PO_MODULE=$2
47
48if [ ! -d ./inc/core ]; then
49     echo "You are not on Dotclear root directory"
50     exit 1
51fi
52
53if [ ! -d locales/_pot ]; then
54     echo "Template not found."
55     exit 1
56fi
57
58extract_strings()
59{
60     $XGETTEXT \
61     -f- \
62     --sort-by-file \
63     -L PHP -k"__:1,2" -k"__:1" \
64     --no-wrap \
65     --foreign-user \
66     --from-code=UTF-8 \
67     "$@"
68}
69
70extract_html_strings()
71{
72     tee -
73
74     $XGETTEXT \
75     - \
76     --sort-by-file \
77     -L PHP -k__ \
78     --no-wrap \
79     --foreign-user \
80     --from-code=UTF-8 \
81     "$@"
82}
83update_po()
84{
85     po_file=$1
86     pot_file=$2
87     po_dir=`dirname $1`
88     po_tmp=$po_dir/tmp.po~
89
90     if [ ! -d $po_dir ]; then
91          mkdir $po_dir
92     fi
93
94     if [ ! -f $po_file ]; then
95          cp $pot_file $po_file
96          perl -pi -e "s|; charset=CHARSET|; charset=UTF-8|sgi;" $po_file $po_file
97     fi
98
99     $MSGMERGE --no-location --no-wrap -o $po_tmp $po_file $pot_file
100     mv $po_tmp $po_file
101}
102
103if [ -z "$PO_MODULE" ]; then
104     #
105     # Create po template files
106     #
107     echo "Building main PO template..."
108     find ./admin ./inc -name '*.php' -not -regex '.*/inc/public/.*' -print | \
109          extract_strings \
110          --package-name="Dotclear 2" \
111          -o locales/_pot/main.pot \
112          -x locales/_pot/date.pot
113
114     echo "DONE"
115
116     # plugins.pot
117     echo "Building plugins PO template..."
118     for p in $PLUGINS; do
119          if [ -d plugins/$p ]; then
120               find ./plugins/$p -name '*.php' -print
121          fi
122     done | \
123          extract_strings \
124          --package-name="Dotclear 2" \
125          -o locales/_pot/plugins.pot \
126          -x locales/_pot/date.pot \
127          -x locales/_pot/main.pot
128
129     echo "DONE"
130
131     #
132     # Update locales/<lang> if needed
133     #
134     if [ -z "$PO_LANG" ]; then
135          exit 0;
136     fi
137
138     # Init locale if not present
139     if [ ! -d locales/$PO_LANG ]; then
140          mkdir -p locales/$PO_LANG/help
141
142          # Base help files
143          for i in locales/en/help/*.html; do
144               cp $i locales/$PO_LANG/help/core_`basename $i`
145          done
146          for i in $PLUGINS; do
147               if [ -f plugins/$i/help.html ]; then
148                    cp plugins/$i/help.html locales/$PO_LANG/help/$i.html
149               fi
150          done
151     fi
152
153     # update main.po
154     echo "Updating <$PO_LANG> po files..."
155     update_po ./locales/$PO_LANG/main.po ./locales/_pot/main.pot
156     update_po ./locales/$PO_LANG/plugins.po ./locales/_pot/plugins.pot
157     update_po ./locales/$PO_LANG/public.po ./locales/_pot/public.pot
158     update_po ./locales/$PO_LANG/date.po ./locales/_pot/date.pot
159else
160     #
161     # Plugin language update
162     #
163
164     if [ ! -d $PO_MODULE ]; then
165          echo "Module $PO_MODULE does not exist"
166          exit 1
167     fi
168     echo "Module $PO_MODULE language update"
169
170
171     #
172     # Building po template file
173     #
174     if [ ! -d $PO_MODULE/locales/_pot ]; then
175          mkdir -p $PO_MODULE/locales/_pot
176     fi
177     echo "Building main PO template..."
178     echo '<?php' >$PO_MODULE/__html_tpl_dummy.php
179     find $PO_MODULE -name '*.html' -exec grep -o '{{tpl:lang [^}]*}}' {} \; | sed 's/{{tpl:lang \(.*\)}}$/__\("\1")/' | sort -u \
180          >> $PO_MODULE/__html_tpl_dummy.php
181     sed -i "" 's/\$/\\\$/g' $PO_MODULE/__html_tpl_dummy.php
182
183     find $PO_MODULE -name '*.php' -print | \
184          extract_strings \
185          --package-name="Dotclear 2 `basename $PO_MODULE` module" \
186          -o $PO_MODULE/locales/_pot/main.pot \
187          -x locales/_pot/date.pot -x locales/_pot/main.pot -x locales/_pot/public.pot -x locales/_pot/plugins.pot
188
189     rm -f $PO_MODULE/__html_tpl_dummy.php
190
191     echo "DONE"
192
193     #
194     # Update locale/<lang>
195     #
196     if [ ! -d $PO_MODULE/locales/$PO_LANG ]; then
197          mkdir -p $PO_MODULE/locales/$PO_LANG
198     fi
199     echo "Updating module <$PO_MODULE> main <$PO_LANG> po file... "
200     update_po $PO_MODULE/locales/$PO_LANG/main.po $PO_MODULE/locales/_pot/main.pot
201fi
Note: See TracBrowser for help on using the repository browser.

Sites map