localization

Django translations does not work

Django translations does not work Question: I’m trying to get Django’s translation system to work, following the tutorial here. Here are my two views (one for direct output, one for template), neither one works. def home(request): output = _(“hello”) # (lazy) return HttpResponse(output) def with_template(request): return render(request, ‘translation_template.html’) here is the template file for the …

Total answers: 10

How to override the django admin translation?

How to override the django admin translation? Question: I’m trying to override the default translations of Django’s admin site. I’m using Django 1.6. My settings.py contains: import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) # … LANGUAGE_CODE = ‘nl’ USE_I18N = True USE_L10N = True LOCALE_PATHS = (os.path.join(BASE_DIR, “locale”),) I have copied the file django/contrib/admin/locale/nl/LC_MESSAGES/django.po to my_project/locale/nl/LC_MESSAGES/django.po and …

Total answers: 1

How do I convert a currency string to a floating point number in Python?

How do I convert a currency string to a floating point number in Python? Question: I have some strings representing numbers with specific currency format, for example: money=”$6,150,593.22″ I want to convert this string into the number 6150593.22 What is the best way to achieve this? Asked By: Javier Novoa C. || Source Answers: If …

Total answers: 10

Why would the makemessages function for Django language localization ignore html files?

Why would the makemessages function for Django language localization ignore html files? Question: I am trying to run the Django language localization on a project, but makemessages always ignores the html templates in my templates folder. I am running python manage.py makemessages -a from the project root, and all of the strings that are marked …

Total answers: 3

Localized date strftime in Django view

Localized date strftime in Django view Question: I would like to send localized date in JSON from django view Normal text translation via ugettext is OK Following code in view has no effect: translation.activate(“ru”) print datetime.now().strtime(“%B”) Output is “August”, instead of “Август“ I read about python’s “locale” module, but it’s named as thread unsafe How …

Total answers: 1

What is the correct way to set Python's locale on Windows?

What is the correct way to set Python's locale on Windows? Question: I’m attempting to sort a list of strings in a locale-aware manner. I’ve used the Babel library for other i18n-related tasks, but it doesn’t support sorting. Python’s locale module provides a strcoll function, but requires the locale of the process to be set …

Total answers: 6