gae-boilerplate
gae-boilerplate copied to clipboard
Use Babel territories for List of Countries
In order to show the countries in any language sopported, we have to use Babel to show the countries with:
from babel import Locale COUNTRIES = Locale('es').territories
here: https://github.com/coto/gae-boilerplate/blob/master/boilerplate/lib/utils.py#L207
We can't use it directly, because it throws the following error:
TypeError: 'NoneType' object is not callable
this page shows how it is intended to be used: http://babel.edgewall.org/wiki/Documentation/0.9/display.html We need the locale object set in the basehandler which determines which language we are using the render the site and then you can call the territories dict from that. The hard part is getting the locale object set in the basehandler.
good point, i'll check it out
On Mon, Oct 8, 2012 at 5:07 PM, Jesse Goodall [email protected]:
this page shows how it is intended to be used: http://babel.edgewall.org/wiki/Documentation/0.9/display.html We need the locale object set in the basehandler which determines which language we are using the render the site and then you can call the territories dict from that. The hard part is getting the locale object set in the basehandler.
— Reply to this email directly or view it on GitHubhttps://github.com/coto/gae-boilerplate/issues/162#issuecomment-9238418.
two more ideas:
- country can be auto-detected using our lib/i18n.py (it is usually done already to determine language).
- if we can't figure out how to get this to work with both babel and wtforms we can either remove it from wtforms or we can remove the countries drop down altogether since it is only a registration demo (or are you actually using it on a project?)
I am using it on a project, but the reason it has country for registration (some time ago I read a research) is because after email, password, username, name and last name, the next most important field for international sites, is Country.
I'm using it on a project as well. Do you want to verify IP address -> country mapping or just take the persons word?