That looks good to me. To avoid mutating Django's default setting (though
it's unlikely to do any harm), I'd do:

from django.conf import global_settings
LANGUAGES = global_settings.LANGUAGES + [('oc', gettext_lazy('Occitan'))]

Would you like to make a documentation PR to reword it to not just talk
about restricting? There are many more languages in the world than in
Django right now!

On Sun, 27 Oct 2019 at 12:34, Yann Sionneau <[email protected]> wrote:

> Hi,
>
> Thanks Adam for your quick answer!
>
> I investigated this a bit more in depth.
>
> It seems that Django cannot use any translation that the visitor would
> want (via cookie or via Accept-Language header) if the language code is not
> in settings.LANGUAGES.
>
> If I read documentation about settings.LANGUAGES :
> https://docs.djangoproject.com/en/2.2/ref/settings/#languages
>
> it says :
>
> "Generally, the default value should suffice. Only set this setting if you
> want to restrict language selection to a subset of the Django-provided
> languages."
>
> So the documentation is talking about *restricting* the list, not
> expanding it.
>
> Anyway, I tried to expand it, it seemed to work.
>
> I did this in my settings file:
>
> LANGUAGES.append(
>     ('oc', gettext_lazy('Occitan')),
> )
>
> Would you say that my understanding is correct? Is my solution correct?
> The best one?
>
> Thanks!
>
> Yann
> Le 25/10/2019 à 15:00, Adam Johnson a écrit :
>
> Hi Yann,
>
> I'm no translation expert, but I believe you can add your own language
> codes in your project and translate your project's strings. To be added to
> core django I think we need (at least some) translation coverage. The last
> language added was Armenian, in this PR:
> https://github.com/django/django/pull/10830 . The translations were first
> submitted on Transifex:
> https://docs.djangoproject.com/en/dev/internals/contributing/localizing/#translations
>
> Thanks,
>
> Adam
>
> On Fri, 25 Oct 2019 at 10:47, Yann Sionneau <[email protected]> wrote:
>
>> Hello,
>>
>> Do you think there would be any show stopper preventing from adding
>> Occitan language in
>>
>> django/conf/locale/__init__.py LANG_INFO ?
>>
>> That would (I think) allow Django apps to use 'oc' translations.
>>
>> Cheers,
>>
>> --
>>
>> Yann
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers  (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/aa5f8eb8-4ad3-e52b-16b8-38aa911a7c2e%40sionneau.net
>> .
>>
>
>
> --
> Adam
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CAMyDDM1YDoNw1%3D21E0UpVMyvygAvJJEZrvS1wHemLvEJbf5F4Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-developers/CAMyDDM1YDoNw1%3D21E0UpVMyvygAvJJEZrvS1wHemLvEJbf5F4Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/e20fa361-9345-fc3f-6844-b0378e81e98d%40sionneau.net
> <https://groups.google.com/d/msgid/django-developers/e20fa361-9345-fc3f-6844-b0378e81e98d%40sionneau.net?utm_medium=email&utm_source=footer>
> .
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM3HwZzHKmTZm%2Bgf3%2BGVjFLOL8TQedg9yk__a0jARj37tA%40mail.gmail.com.

Reply via email to