source: trunk/i18n/utils/updateTranslation.sh @ 2447

Revision 2447, 2.5 KB checked in by anonymous, 11 years ago (diff)

Added custom version of pygettext, that can handle default values for
msgids.

  • Property svn:executable set to *
Line 
1#!/bin/bash
2# Note: this requires Plone, i18ndude, and LeMill installed, and should be run
3# from Products/LeMill/i18n (like: utils/updateTranslation.sh)
4
5head -n 18 lemill.pot >lemill-head.pot
6
7# Generate new strings from source, then add anything that was in the previous pot
8i18ndude rebuild-pot --pot lemill-skin.pot --create lemill --merge lemill-head.pot ../skins/
9rm lemill-head.pot
10if [ -r lemill-skin.pot ]; then
11  echo "Skins processed ok:" $(cat lemill-skin.pot|grep 'msgid'|wc -l)
12else
13 echo "Problem processing skins!" && exit 1
14fi
15
16# Extract data from live site
17cd ../tests
18./runtests.sh extractTranslations.py
19if [ -r lemill-generated.pot ]; then
20  echo "Site processed ok: " $(cat lemill-generated.pot|grep 'msgid'|wc -l)
21  mv lemill-generated.pot ../i18n
22  cd ../i18n
23else
24  echo "Error processing site!"
25  exit 2
26fi
27
28cd ..
29i18n/utils/pygettext.py -oi18n/lemill-gettext.pot *.py
30cd i18n
31echo "Python files harvested ok: " $(cat lemill-gettext.pot|grep 'msgid'|wc -l)
32
33# Filter Plone stuff out
34PRODUCTS_FOLDER=$(pwd)
35PRODUCTS_FOLDER=${PRODUCTS_FOLDER/\/LeMill\/i18n//}
36i18ndude filter lemill-generated.pot ${PRODUCTS_FOLDER}PloneTranslations/i18n/plone.pot >lemill-generated2.pot || { echo "Problem filtering generated catalog!"; exit 3; }
37echo "Skin catalog filtered with Plone: " $(cat lemill-generated2.pot|grep 'msgid'|wc -l)
38rm lemill-generated.pot
39
40# Merge
41i18ndude merge --pot lemill-generated2.pot --merge lemill-skin.pot || { echo "Problem merging pots!"; exit 4; }
42echo "Catalogs merged #1: " $(cat lemill-generated2.pot|grep 'msgid'|wc -l)
43i18ndude merge --pot lemill-generated2.pot --merge utils/extramsgids.txt || { echo "Problem merging pots!"; exit 4; }
44echo "Catalogs merged #2: " $(cat lemill-generated2.pot|grep 'msgid'|wc -l)
45i18ndude merge --pot lemill-generated2.pot --merge lemill-gettext.pot || { echo "Problem merging pots!"; exit 4; }
46echo "Catalogs merged #3: " $(cat lemill-generated2.pot|grep 'msgid'|wc -l)
47rm lemill-skin.pot lemill-gettext.pot
48
49# Remove extra strings (because i18ndude generates some unneeded stuff)
50i18ndude filter lemill-generated2.pot utils/unusedmsgids.txt >lemill-generated3.pot || { echo "Problem filtering!"; exit 4; }
51rm lemill-generated2.pot
52echo "Catalog filtered: " $(cat lemill-generated3.pot|grep 'msgid'|wc -l)
53
54mv lemill.pot lemill.pot.old
55mv lemill-generated3.pot lemill.pot
56
57# Update all translations
58i18ndude sync --pot lemill.pot lemill-*.po || { echo "Problem syncing translations!"; exit 5; }
59
60# Update english file
61utils/gen-lemill-en.py
62
63echo "Done!"
Note: See TracBrowser for help on using the repository browser.