summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNeill Cox <neill@ingenious.com.au>2015-06-16 11:50:51 +1000
committerNeill Cox <neill@ingenious.com.au>2015-07-02 11:13:45 +1000
commit9b36822fe26a8dc7f0ba7f74f3eb131a1b129e25 (patch)
tree6c22733065b4afbdce31d28dd84a49bb9efb862d /tools
parent94542b6d7e9d47295c8f67157ef168b476bb7781 (diff)
downloadhorizon-9b36822fe26a8dc7f0ba7f74f3eb131a1b129e25.tar.gz
Angular translation via babel (singular only)
An approach to i18n for Angular HTML templates using babel. This patch allows only singular translation. Plurals and context will be addressed in subsequent patches. Based on Thai Tran's work at https://review.openstack.org/#/c/187321 This patch implements a custom extractor in horizon/utils/babel_extract_angular.py. pybabel really wants this to be a package installed into site-packages. I have not done this so as to avoid introducing a dependency on another change to global requirements just yet. I will upload a package to pypi in parallel so that we can start using it in the future. For now, I have had to modify tools/with_venv.sh to add horizon to the PYTHONPATH. This is less than ideal but seemed to be the least worst option. Steps to verify that it works: 1. Create a new html file in horizon/static or openstack_dashboard/static 2. Add something like <div translate>hello world!</div> to the html To test interpolation add something like: <div translate>hello {$name$}!</div> 3. Run ./run_tests.sh --makemessages 4. Inspect your djangojs.po file, it should be there. The following steps are optional: 5. Run ./run_tests.sh --pseudo de 6. Run ./run_tests.sh --compilemessages 7. Go to http://localhost:8000/settings 8. Change Language to Deutsch 9. Go to http://localhost:8000/i18n/js/horizon+openstack_dashboard 10. Your translated text should be there as well. Note: There are now unit tests as well. Partially-Implements: blueprint angular-translate-makemessages Depends on: If4352aba01ce0ca6337f590c0689d8fe9f0867c8 Change-Id: I26d4fef8646d5f038918cd3376dbbdbef37eb603
Diffstat (limited to 'tools')
-rwxr-xr-xtools/with_venv.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/with_venv.sh b/tools/with_venv.sh
index 7303990bd..f4170c9a7 100755
--- a/tools/with_venv.sh
+++ b/tools/with_venv.sh
@@ -4,4 +4,10 @@ VENV_PATH=${VENV_PATH:-${TOOLS_PATH}}
VENV_DIR=${VENV_NAME:-/../.venv}
TOOLS=${TOOLS_PATH}
VENV=${VENV:-${VENV_PATH}/${VENV_DIR}}
+HORIZON_DIR=${TOOLS%/tools}
+
+# This horrible mangling of the PYTHONPATH is required to get the
+# babel-angular-gettext extractor to work. To fix this the extractor needs to
+# be packaged on pypi and added to global requirements. That work is in progress.
+export PYTHONPATH="$HORIZON_DIR"
source ${VENV}/bin/activate && "$@"