Closed zarino closed 8 years ago
A few observations:
get_language_info
corrupts the language codes and names of languages not built into Django. It works fine with Argentinian Spanish:
In [1]: from django.utils import translation
In [2]: from django.conf import settings
In [3]: settings.LANGUAGES
Out[3]:
[('el', 'Greek'),
('en', 'English'),
('es-ar', 'Argentinian Spanish'),
('fr', 'French'),
('cy-gb', 'Welsh'),
('es-cr', 'Costa Rican Spanish')]
In [4]: translation.get_language_info('es-ar')
Out[4]:
{'bidi': False,
'code': 'es-ar',
'name': 'Argentinian Spanish',
'name_local': 'español de Argentina'}
But not the Costa Rican variety:
In [5]: translation.get_language_info('es-cr')
Out[5]: {'bidi': False, 'code': 'es', 'name': 'Spanish', 'name_local': 'español'}
I think it'd be best to bypass We can extend get_language_info_list
and list our languages for translation in mysite.extra_translations
.django.conf.locale.LANG_INFO
with Costa Rican Spanish and Welsh.
User-Agent
locale as the default locale.It should be possible to POST on click/select with XHR, serving the original dropdown to clients that support JavaScript. Having to press 'Go' is not ideal.
Already working on it! 👍
@struan @mhl: Commit 31bb5384af1e215ff7acb74ba07cf19924dc2840 reverts all the custom dropdown menu styling and instead styles up the <select>
element. If JavaScript is available, the submit button is hidden, and the form is automatically submitted whenever you change the <select>
value.
Styling select boxes is the devil’s work, so I’ve tested this in IE8 and above, modern and old Firefox, and a few versions of Safari to check it all looks ok. In IE8–9 you get a duplication of dropdown arrows (one on the left, one on the right) but I think that's acceptable.
I think @wfdd's first point still needs to be addressed here - I'm assuming that's why the following fails:
Language switcher for #676.
Closed:![closed](https://cloud.githubusercontent.com/assets/739624/15154035/8e0d2c48-16d3-11e6-954e-ea3c919e3d53.png)
Open:![open](https://cloud.githubusercontent.com/assets/739624/15154036/8f6ad680-16d3-11e6-84e3-32ead174ffe7.png)
Feels a bit fiddly. Will revisit tomorrow morning with fresh eyes.