Last active
August 29, 2015 14:19
-
-
Save beck/b73b83ce0b625b030aea to your computer and use it in GitHub Desktop.
because django's jsi18n js makes me sad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if LANGUAGE_CODE == 'en' %} | |
{% compress js inline %} | |
<script> | |
window.json_locale_data = { | |
"messages": {}, | |
"locale": "en", | |
"lang": "en" | |
}; | |
</script> | |
{% endcompress %} | |
{% elif LANGUAGE_CODE == 'de' %} | |
{% compress js %}<script src="{{STATIC_URL}}compiled/i18n/de/messages.js"></script>{% endcompress %} | |
{% elif LANGUAGE_CODE == 'es' %} | |
{% compress js %}<script src="{{STATIC_URL}}compiled/i18n/es/messages.js"></script>{% endcompress %} | |
{% elif LANGUAGE_CODE == 'fr' %} | |
{% compress js %}<script src="{{STATIC_URL}}compiled/i18n/fr/messages.js"></script>{% endcompress %} | |
{% elif LANGUAGE_CODE == 'it' %} | |
{% compress js %}<script src="{{STATIC_URL}}compiled/i18n/it/messages.js"></script>{% endcompress %} | |
{% elif LANGUAGE_CODE == 'pt-br' %} | |
{% compress js %}<script src="{{STATIC_URL}}compiled/i18n/pt_BR/messages.js"></script>{% endcompress %} | |
{% endif %} | |
{% comment %} | |
POs are converted to JS catalogs during build. | |
Example grunt task using: | |
https://github.com/mozilla/i18n-abide#popot-files | |
```js | |
grunt.initConfig({ | |
abideCompile: { | |
javascriptCatalogs: { | |
dest: 'collected_static/compiled/i18n', | |
options: { | |
type: 'json', | |
localeDir: 'collected_static/compiled/locale', | |
} | |
} | |
} | |
}) | |
``` | |
And using gettext function: | |
https://github.com/beck/i18n-abide-gettext/blob/master/gettext.js | |
{% endcomment %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment