Commit Graph

3 Commits

Author SHA1 Message Date
Akihiro Motoki 155bf22788 Drop babel extractor definitions from babel config
Babel allows us to register babel extractors via entry points.
This means we no longer need to have extractor definitions in
each babel config files. All horizon plugins have copies of
babel-django.cfg and babel-djangojs.cfg now. By dropping the
extractor defintiions from babel config files, we can make
a potential migration from django-babel to enmerkar (and
we can also avoid more modifications of babel config files
even if more transition is required).

django-babel and enmerkar both define 'django' extractor
in the entry point, so we can drop it from babel-django.cfg.
This commit also registers 'angular' extractor, so we can drop
the extractor for AngularJS from babel-djangojs.cfg.

Change-Id: Icf93d4551bd3db1baa84c110f06dcc1c36e18b7e
2019-12-23 17:25:38 +09:00
Neill Cox 9b36822fe2 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
2015-07-02 11:13:45 +10:00
Neill Cox 4e0b09a357 Replace makemessages with babel
Replace django's makemessages with babel and babel-django.

This changes the makemessages command to use babel rather than
Django's builtin makemessages.

There is a follow on patch to add support for angular-gettext.

Change-Id: If4352aba01ce0ca6337f590c0689d8fe9f0867c8
Depends-On: Iaa835b03af3929b7314b174210079c34de976755
2015-06-22 09:44:12 -07:00