jazzband / django-recurrence

Utility for working with recurring dates in Django.
https://django-recurrence.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
489 stars 190 forks source link

Adding Russian i18n #80

Open vsalex opened 7 years ago

vsalex commented 7 years ago

Thank you for so much for this great project!

I'm working on Django 1.8 project with Russian language and i want use your application. But i can't deal with languages in it. I found different locales in recurrence/locale and i know how gettext is working but when i change my default Django language to some locale that are already presented in locale e.g. i set

LANGUAGE_CODE = 'fr'

admin language are changing to French language, but recurrence widget is still in English. Also i add js i18n url:

js_info_dict = {
    'packages': ('recurrence', ),
}
# jsi18n can be anything you like here
urlpatterns += (
    url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)

But JS widget is still use English. What am i doing wrong?

ps. I want to add Russian localization on reccurence project but at this point i can't uderstand why i18n doesn't work for me.

dominicrodger commented 7 years ago

Hi @vsalex. In your form's template, are you including {{ form.media }} somewhere?

vsalex commented 7 years ago

Hello @dominicrodger. Thank you for answering. Yes i have according to docs:

Be sure to add {{ form.media }} to your template or statically link recurrence.css and recurrence.js.

static links to recurrence.css and recurrence.js in my admin template:

<link href="/static/recurrence/css/recurrence.css" type="text/css" media="all" rel="stylesheet" />
...
<script type="text/javascript" src="/static/recurrence/js/recurrence.js"></script>
<script type="text/javascript" src="/static/recurrence/js/recurrence-widget.js"></script>

but still can not change language of JS widget.

dominicrodger commented 7 years ago

I see. You'll also need to make sure you've followed the steps here. That should mean you end up with 3 JavaScript files - one of which is the JS i18n library. Let me know if that doesn't fix it.

dominicrodger commented 7 years ago

Also - if that's what it is, we can definitely do a better job at improving the documentation to make it clearer.

vsalex commented 7 years ago

@dominicrodger thank you. This is very strange but on clean Django 1.8 project i18n is worked perfectly. So something wrong with my working project. I will check it.

I try to add Russian i18n on this week and make commit.

Also there is mistake in docs about Django 1.8. Now it is:

urlpatterns = patterns(
    '',
    (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)

And should be:

urlpatterns += (
    url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)
dominicrodger commented 7 years ago

Odd, OK. Let me know if you work out what's wrong.

I see what you mean about the docs. They're intended to show what you need if you were to have the i18n views as the only views in your project (which is obviously not something you'd want in real life), but having += makes more sense, and means people can just cut-and-paste the code into their urls.py, which people would find useful I expect.