Changeset 3784:5df288cba61f for build-tools/po_update.sh
- Timestamp:
- 07/26/18 16:19:33 (7 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
build-tools/po_update.sh
r3731 r3784 41 41 42 42 if [ ! -d ./inc/core ]; then 43 44 43 echo "You are not on Dotclear root directory" 44 exit 1 45 45 fi 46 46 47 47 if [ ! -d locales/_pot ]; then 48 49 48 echo "Template not found." 49 exit 1 50 50 fi 51 51 52 52 extract_strings() 53 53 { 54 55 56 57 58 59 60 61 54 $XGETTEXT \ 55 -f- \ 56 --sort-by-file \ 57 -L PHP -k"__:1,2" -k"__:1" \ 58 --no-wrap \ 59 --foreign-user \ 60 --from-code=UTF-8 \ 61 "$@" 62 62 } 63 63 64 64 extract_html_strings() 65 65 { 66 66 tee - 67 67 68 69 70 71 72 73 74 75 68 $XGETTEXT \ 69 - \ 70 --sort-by-file \ 71 -L PHP -k__ \ 72 --no-wrap \ 73 --foreign-user \ 74 --from-code=UTF-8 \ 75 "$@" 76 76 } 77 77 update_po() 78 78 { 79 80 81 82 79 po_file=$1 80 pot_file=$2 81 po_dir=`dirname $1` 82 po_tmp=$po_dir/tmp.po~ 83 83 84 85 86 84 if [ ! -d $po_dir ]; then 85 mkdir $po_dir 86 fi 87 87 88 89 90 91 88 if [ ! -f $po_file ]; then 89 cp $pot_file $po_file 90 perl -pi -e "s|; charset=CHARSET|; charset=UTF-8|sgi;" $po_file $po_file 91 fi 92 92 93 94 93 $MSGMERGE --no-location --no-wrap -o $po_tmp $po_file $pot_file 94 mv $po_tmp $po_file 95 95 } 96 96 97 97 if [ -z "$PO_MODULE" ]; then 98 99 100 101 102 find ./admin ./inc -name '*.php' -not -regex '.*/inc/public/.*' -print | \103 104 105 106 98 # 99 # Create po template files 100 # 101 echo "Building main PO template..." 102 find ./admin ./inc -name '*.php' -not -regex '.*/inc/public/.*' -not -regex '.*/inc/libs/.*' -print | \ 103 extract_strings \ 104 --package-name="Dotclear 2" \ 105 -o locales/_pot/main.pot \ 106 -x locales/_pot/date.pot 107 107 108 108 echo "DONE" 109 109 110 111 112 113 114 115 116 117 118 119 120 121 110 # plugins.pot 111 echo "Building plugins PO template..." 112 for p in $PLUGINS; do 113 if [ -d plugins/$p ]; then 114 find ./plugins/$p -name '*.php' -print 115 fi 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 122 123 123 echo "DONE" 124 124 125 126 127 128 129 130 125 # 126 # Update locales/<lang> if needed 127 # 128 if [ -z "$PO_LANG" ]; then 129 exit 0; 130 fi 131 131 132 133 134 132 # Init locale if not present 133 if [ ! -d locales/$PO_LANG ]; then 134 mkdir -p locales/$PO_LANG/help 135 135 136 137 138 139 140 141 142 143 144 145 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 146 147 148 149 150 151 152 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 153 153 else 154 155 156 154 # 155 # Plugin language update 156 # 157 157 158 159 160 161 162 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 163 164 164 165 166 167 168 169 170 171 172 173 174 175 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 176 177 178 179 180 181 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 182 183 183 rm -f $PO_MODULE/__html_tpl_dummy.php 184 184 185 185 echo "DONE" 186 186 187 188 189 190 191 192 193 194 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 195 195 fi
Note: See TracChangeset
for help on using the changeset viewer.