From 0f6622c374af25c7afa5533decced961d38b76cb Mon Sep 17 00:00:00 2001 From: Austin King Date: Fri, 14 Jan 2011 15:01:24 -0800 Subject: [PATCH] Moving compile-mo into bin and integrating locale/README into docs --- bin/compile-mo.sh | 19 +++++++++++++++++++ docs/index.rst | 1 + docs/l10n_setup.rst | 17 ++++++++++++----- docs/l10n_update.rst | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100755 bin/compile-mo.sh create mode 100644 docs/l10n_update.rst diff --git a/bin/compile-mo.sh b/bin/compile-mo.sh new file mode 100755 index 0000000..8330cac --- /dev/null +++ b/bin/compile-mo.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# syntax: +# compile-mo.sh locale-dir/ + +function usage() { + echo "syntax:" + echo "compile.sh locale-dir/" + exit 1 +} + +# check if file and dir are there +if [[ ($# -ne 1) || (! -d "$1") ]]; then usage; fi + +for lang in `find $1 -type f -name "*.po"`; do + dir=`dirname $lang` + stem=`basename $lang .po` + msgfmt -o ${dir}/${stem}.mo $lang +done diff --git a/docs/index.rst b/docs/index.rst index 336cc35..7e7131d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -30,6 +30,7 @@ Contents gettingstarted libs l10n_setup + l10n_update Indices and tables diff --git a/docs/l10n_setup.rst b/docs/l10n_setup.rst index 6946654..2f9af7c 100644 --- a/docs/l10n_setup.rst +++ b/docs/l10n_setup.rst @@ -6,21 +6,29 @@ So you'd like to localize your webapp. **Congratulations!** Playdoh comes with all of the libraries and tools you need in the dev and production requirements. +Requirements +------------ + +The one set of low level tools not provided is gettext. + +:: + + aptitutde install gettext + Steps ----- The following steps will get you started: -#. Create a SVN reposity based on MDN_ locale directory. - This will give you a README.txt, compile-mo.sh, and - show you the proper directory layout. +#. Create a SVN reposity with directories based on MDN_ + locale directory. Playdoh comes with bin/complie-mo.sh #. Compile the po files and mirror the SVN repository in a git repository via a cron job that runs every 15 minutes. Example: (TBD) /home/fwenzel/bin/autol10n/autol10n.sh #. Add your git repo as an external to this project It should create a locale directory at the top level -#. Read locale/README.txt for a better understanding of +#. Read the next section L10n udpate for a better understanding of what Django management commands are used to extract and merge strings into your po files. It has instructions for adding more locales. @@ -28,7 +36,6 @@ The following steps will get you started: Q&A --- Why SVN? Our localizers like to use either SVN or Verbatim. - Why a git repo to mirror an SVN repo? This allows us to have an external reference and update easily. .. _MDN: http://svn.mozilla.org/projects/mdn/trunk/locale/ diff --git a/docs/l10n_update.rst b/docs/l10n_update.rst new file mode 100644 index 0000000..984bbab --- /dev/null +++ b/docs/l10n_update.rst @@ -0,0 +1,43 @@ +L10n Update +=========== + +Follow these steps to update strings for L10n. + +We are using English strings for gettext message ids. + +Environment Setup +----------------- + +Your top level directory named locale should be an SVN repository. +This is because we will generate files there and we'll +commit via SVN. Developers who never deal with L10n +do not need to worry about this kind of setup. It's often +easier to have a L10n dev setup, which a cron job updates +the sources, updates the strings, and compiles the po +files and lastly commiting to SVN. + +Instructions: +------------- + +1. ``./manage.py extract `` +2. ``./manage.py verbatimize --rename`` + This will copy the POT files created in step 1 to templates/LC_MESSAGES +3. ``./manage.py merge`` + +Optional: +--------- + +4. ``locale/compile-mo.sh locale`` + +New Locales: +------------ + +Assuming you want to add 'fr': + +#. ``mkdir -p locale/fr/LC_MESSAGES`` +#. ``./manage.py merge`` + +or + +#. ``msginit --no-translator -l fr -i templates/LC_MESSAGES/messages.pot -o fr/LC_MESSAGES/messages.po`` +#. repeat for other POT files