Search code examples
djangodjango-countries

Django-countries: How to translate?


I have installed django countries today. It works pretty neat.

The documentation is unfortunately a bit thin, it says:

COUNTRIES A tuple of two part tuples, each consisting of a country code and the corresponding nicely titled (and translatable) country name.

Do I simply go down the usual path of django internationalization and it would automatically pick it up and allow me to define the countries in my PO file? Or is there any additional magic required?

The way I have implemented it is like this:

from django_countries.countries import COUNTRIES
from django_countries.fields import CountryField

country             = CountryField(_(u'Country'), choices=COUNTRIES,  blank=True)

COUNTRIES is coming directly from the extension, therefore I have no access to put _(u) around each country name. (from django.utils.translation import ugettext_lazy as _)


Solution

  • Just follow the django translation documentation and it will automatically add the ugettext_lazy marked strings into your .po file. And then provide message strings according to the language of your choice.