def get_i18n_js(self):
        """Generates a Javascript body for i18n in Javascript.

        If you want to load these javascript code from a static HTML
        file, you need to create another handler which just returns
        the code generated by this function.

        Returns:
            Actual javascript code for functions and translation
            messages for i18n.
        """

        try:
            js_translations = gettext.translation(
                'jsmessages', 'locales', fallback=False,
                languages=self.request.environ[
                    'i18n_utils.preferred_languages'],
                codeset='utf-8')
        except __HOLE__:
            template = self.jinja2_env.get_template('null_i18n_js.jinja2')
            return template.render()

        translations_dict = convert_translations_to_dict(js_translations)
        template = self.jinja2_env.get_template('i18n_js.jinja2')
        return template.render(
            {'translations': json.dumps(translations_dict, indent=1)})
dataset/ETHPy150Open GoogleCloudPlatform/python-docs-samples/appengine/i18n/i18n_utils.py/BaseHandler.get_i18n_js