If you look at the source code of Django 1.8 you see that widget rendering, 
*when 
it's localized*, takes the first element [0] of the translation table watch 
end of the last line :

class DateTimeBaseInput(TextInput):
    # blabla
    def _format_value(self, value):
        return formats.localize_input(value,
            self.format or formats.get_format(self.format_key)[0])


So if you create a DateInput, the code source shows :

class DateInput(DateTimeBaseInput):
    format_key = 'DATE_INPUT_FORMATS'


so when it's rendered, it will call formats.get_format('DATE_INPUT_FORMATS'
)[0])

so I've made my own form like this:

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Personne
        fields = ('date_naissance',)

    e = {'required': _(u'This field is required'),
         'invalid': _(u'This field contains invalid data')}
    a = _(u'Birthdate:')
    date_naissance = forms.DateField(
        label=a, localize=True,
        widget=DateLocalizedWidget(attrs={
            'title': a,
            'class': 'form-control datetimepicker'}))

    def __init__(self, *args, **kwargs):
        super(ProfileForm, self).__init__(*args, **kwargs)
        print(get_language(), u'-->', formats.get_format('DATE_INPUT_FORMATS'))

and in the I've tried to ouput the format of 

so when I show a french page, I get:

*(u'fr', u'-->', [u'%d/%m/%Y', u'%d/%m/%y', u'%d.%m.%Y', u'%d.%m.%y', 
'%Y-%m-%d'])*

and when it's in english I get:
*(u'en', u'-->', (u'%Y-%m-%d', u'%m/%d/%Y', u'%m/%d/%y'))*

so it takes the [0] element (see above). Shouldn't the first element be 
*'%m/%d/%Y'* in english ?
If you output all langages with this code:

for i in ['af', 'ar', 'ast', 'az', 'be', 'bg', 'bn', 'br', 'bs', 'ca',
          'cs', 'cy', 'da', 'de', 'de_CH', 'el', 'en', 'en_AU',
          'en_GB', 'eo', 'es','et', 'eu', 'fa', 'fi', 'fr', 'fy', 'ga',
          'gl', 'he', 'hhh', 'hi', 'hr', 'hu', 'ia', 'id', 'io', 'is',
          'it', 'ja', 'ka', 'kk', 'km', 'kn', 'ko', 'lb', 'lt', 'lv',
          'mk', 'ml', 'mn', 'mr', 'my', 'nb', 'ne', 'nl', 'nn', 'os',
          'pa', 'pl', 'pt', 'pt_BR', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr',
          'sv', 'sw', 'ta', 'te', 'th', 'tr', 'tt', 'udm', 'uk', 'ur',
          'vi']:
    translation.activate(i)
    print(get_language(), u'-->', formats.get_format('DATE_INPUT_FORMATS')[0])


you will get a mess: either it's close to *'%m/%d/%Y'*, or it's close 
*'%Y-%m-%d'* which is not homogeneous at all.
What should we do?


-- 
You received this message because you are subscribed to the Google Groups 
"Django internationalization and localization" 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 https://groups.google.com/group/django-i18n.
For more options, visit https://groups.google.com/d/optout.

Reply via email to