How to make your translations available to your UI built with AngularJS

This guide is kindly provided by Colin Sippl from the University Library of Regensburg.


The Invenio internationalisation module invenio-i18n provides you with Jinja2 macros and filters for i18N to display translated text in templates. However, translations are not available in the AngularJS app.


You can use the AngularJS extension angular-gettext to load the translations and make them available in the AngularJS app. The extension adds a new filter translate that can be used in AngularJS templates, for example <p>{{ ('Hello world!' | translate) }}<p>.

The following example will refer to a new Invenio 3.2 installation, with site name my_site.

  1. Create the new language using Python Babel:

pybabel init -i my_site/translations/de/LC_MESSAGES/messages.pot -d my_site/translations -l de

  1. Compile the new language:

pybabel compile -d my_site/translations

  1. Create a new AngularJS translation module inside the AngularJS modules folder, e.g. /my_site/translation.js:
    .run(['gettextCatalog', function (gettextCatalog) {
  1. Make sure to add this new module as a dependency to your app.js:
 (function (angular) {
   angular.element(document).ready(function() {
       document.getElementById("invenio-search-app"), [
         'invenioSearch', 'mySiteAppTranslations'
  1. Add the app.js and the translation.js files as well as the angular-gettext NPM dependency to your or Don’t forget it to update the Python entry points in the if this is a new file. Add also AngularGettextFilter to compile GNU gettext messages to angular-gettext module.
"""JS/CSS bundles for theme."""

import os

from flask_assets import Bundle
from invenio_assets import NpmBundle, AngularGettextFilter, GlobBundle
from pkg_resources import resource_filename

# see RERO-ILS
# loads translations from messages catalog
def catalog(domain):
    """Return glob matching path to translated messages for a given domain."""
    return os.path.join(
        os.path.abspath(resource_filename('my_site', 'translations')),
        '*',  # language code

i18n = GlobBundle(

js = NpmBundle(
        'angular': '~1.4.9',
        'angular-gettext': '~2.4.1',