On Wednesday 22 January 2014 18:29:18 Henrique Romano wrote:
> On Wed, Jan 22, 2014 at 2:16 PM, Shai Berger <[email protected]> wrote:
> > Wait -- so the real context (which, as Ramiro noted, you left out) is
> > 
> > # settings.py
> > 
> > LANGUAGES = (('pt_BR', _("Português")),)
> > 
> > Is it? Or is it
> > 
> > LANGUAGES = (('pt_BR', "Português"),)
> > 
> > If it is the former, then this is a generic issue of translatable strings
> > --
> > nothing to do with settings.LANGUAGES. It is usually assumed that, if you
> > are
> > making a string translatable, you write it in English -- then it's ASCII
> > and
> > all's well.
> > 
> > If it is the latter, please provide more details about the specific error
> > you
> > encountered (stack traces etc).
> 
> > In my test, LANGUAGES is defined as follows:
> LANGUAGES = [
>     ('en-us', 'English'),
>     ('pt-br', 'Português'),
> ]
> 
> As the documentation didn't make it clear that the language names should be
> unicode, I just used the translated name ("Português") in a plain string, I
> thought it would be OK since settings.py has the encoding declared at the
> top of the file.
> 
> As for the error, it happened inside django-cms.  There's a code that is
> called for building a list of the languages enabled and their names:
> 
> # cms/utils/i18n.py
>  19 def get_languages(site_id=None):
>  20     site_id = get_site(site_id)
>  21     result = get_cms_setting('LANGUAGES').get(site_id)
>  22     if not result:
>  23         result = []
>  24         defaults = get_cms_setting('LANGUAGES').get('default', {})
>  25         for code, name in settings.LANGUAGES:
>  26             lang = {'code': code, 'name': _(name)}
>  27             lang.update(defaults)
>  28             result.append(lang)
>  29         get_cms_setting('LANGUAGES')[site_id] = result
>  30     return result
> 
> In the code above it is trying to translate the language name and it is
> resulting in an error since the name isn't an unicode string.  I understand
> that this is happening in django-cms, but I still think it is relevant to
> document either that the name should be a unicode string or at least the
> english name of the language.

I don't think Django should take responsibility for a 3rd-party package which 
decides that some part of a setting should be translatable whether the user 
said so or not.

You might want to take this up with django-cms.

Shai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/201401221838.24696.shai%40platonix.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to