pydanny / django-wysiwyg

A Django application for making Django textareas rich text editors. Certainly as a template tag and possibly as a form widget.
http://django-wysiwyg.readthedocs.org
MIT License
465 stars 63 forks source link

Internationalization support #19

Closed fmp-martins closed 12 years ago

fmp-martins commented 12 years ago

How can I get in18n support? I'm developing a multilanguage website and the it always shows the GUI in english.

pydanny commented 12 years ago

I'm not sure how to i18n JavaScript. Have you done it before?

fmp-martins commented 12 years ago

Yes.

You can do it using {% trans %} directly in you JavaScript (when the script is in your template), like:

{% block jsgallery %}
<script type="text/javascript">
function startGallery() {
    var myGallery = new gallery($('myGallery'), {
        timed: {{has_extra_pictures}},
        showArrows: {{has_extra_pictures}},
        showCarousel: {{has_extra_pictures}},
        textShowCarousel: '{% trans "Pictures" %}',
        showInfopane: false,
        embedLinks: false}
    );
}
window.addEvent('domready', startGallery);
</script>
{% endblock %}

or you provide all the translations with you JavaScript script, like I explain in this jQuery date picker integration (last code example): http://blog.hexonio.com/2012/03/07/calendar-picker-django-forms/