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 *
RevLine 
[0]1#!/bin/sh
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
[1179]6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
[0]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
[750]25attachments
[0]26blogroll
27blowupConfig
[3009]28breadcrumb
[2283]29dclegacy
[0]30fairTrackbacks
31importExport
32maintenance
33pages
34pings
[750]35simpleMenu
[0]36tags
37themeEditor
[750]38userPref
[0]39widgets
[2739]40dcLegacyEditor
41dcCKEditor
[1977]42_fake_plugin
[0]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 \
[1944]63     -L PHP -k"__:1,2" -k"__:1" \
[0]64     --no-wrap \
65     --foreign-user \
[750]66     --from-code=UTF-8 \
[0]67     "$@"
68}
69
70extract_html_strings()
71{
72     tee -
[2566]73
[0]74     $XGETTEXT \
75     - \
76     --sort-by-file \
77     -L PHP -k__ \
78     --no-wrap \
79     --foreign-user \
[750]80     --from-code=UTF-8 \
[0]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~
[2566]89
[0]90     if [ ! -d $po_dir ]; then
91          mkdir $po_dir
92     fi
[2566]93
[0]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
[2566]98
[0]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
[2566]113
[0]114     echo "DONE"
[2566]115
[0]116     # plugins.pot
117     echo "Building plugins PO template..."
118     for p in $PLUGINS; do
[1977]119          if [ -d plugins/$p ]; then
120               find ./plugins/$p -name '*.php' -print
121          fi
[0]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
[2566]128
[0]129     echo "DONE"
[2566]130
[0]131     #
132     # Update locales/<lang> if needed
133     #
134     if [ -z "$PO_LANG" ]; then
135          exit 0;
136     fi
[2566]137
[0]138     # Init locale if not present
139     if [ ! -d locales/$PO_LANG ]; then
140          mkdir -p locales/$PO_LANG/help
[2566]141
[0]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
[2566]152
[0]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     #
[2566]163
[0]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"
[2566]169
170
[0]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..."
[2566]178     echo '<?php' >$PO_MODULE/__html_tpl_dummy.php
[0]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
[2566]181     sed -i "" 's/\$/\\\$/g' $PO_MODULE/__html_tpl_dummy.php
182
[0]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
[2566]188
[0]189     rm -f $PO_MODULE/__html_tpl_dummy.php
[2566]190
[0]191     echo "DONE"
[2566]192
[0]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