Menu
  • HOME
  • TAGS

Django i18n pattern

python,django,internationalization,django-i18n

The issue was that Django didn't add request.session['django_language'] = lang_code I just extend locale middleware and use the following code. def process_request(self, request): if self.is_language_prefix_patterns_used(): lang_code = (get_language_from_path(request.path_info) or request.session.get('django_language', settings.LANGUAGE_CODE)) activate(lang_code) request.session['django_language'] = lang_code request.LANGUAGE_CODE = get_language() Now, I have following question. What should I do so that http://localhost:8000...

How do I run makemessages so it includes some apps that are outside the Django project?

python,django,django-apps,django-i18n

I need to create symlinks in the django project: cd my_django_project ln -s ../apps/app1/app1 . and then I need to add an extra parameter to follow synlinks: ./manage.py makemessages -l fr --symlinks EDIT: A better way to fix this is to add a locale directory in the folder app, and...

Django: blocktrans entry is not being translated

django,django-i18n

It's not translated because {{house_type}} will have the value of house_post.house_type.name. The blocktrans actually does nothing in your code. You would need it if you want to add a translatable text to the sentence. Ex: {% blocktrans with house_type=house_post.house_type.name trimmed %} {{house_type}} Translate this part {% endblocktrans %} If you...

Django translations block not translated [duplicate]

django,templates,translation,percentage,django-i18n

I found a simple solution, maybe even better than the one suggested in Handling percent-sign (%) in Django blocktrans tags {% blocktrans with percent="%" %} This is 100{{ percent }} working! {% endblocktrans %} ...

Django Switch language with i18n pattern and normal url_pattern

python,django,python-2.7,internationalization,django-i18n

Ok so I managed to make it work I just had to add {% language lang_code %} to my link. Now I've my urls which are working with a generic next value. <ul class="lang-switch"> {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} {% language lang_code...

Django, change language while redirecting

python,django,django-i18n

You can change language explicitly after login like this: from django.utils import translation user_language = 'en' translation.activate(user_language) request.session['django_language'] = user_language activate() will change the language for thread only, while changing the session makes it persistent in future requests....

Django. i18N reverse url Issue

python,django,reverse,django-i18n

I think your problem is connected with cronjob locale settings: you can do instead is create (if not already present) the file /etc/environment and add the following line: LANG=pl_PL.UTF-8 change your command: class Command(BaseCommand): can_import_settings = True def handle(self, *args, **options): # Activate a fixed locale, e.g. Polish translation.activate('pl') #...

When using i18n_patterns, how to reverse url without language code

django,django-i18n

I think the easiest way is to let Django resolve the URL with the language prefix and then just remove the language prefix. You can write the following function: import re from django.core.urlresolvers import reverse def reverse_no_i18n(viewname, *args, **kwargs): result = reverse(viewname, *args, **kwargs) m = re.match(r'(/[^/]*)(/.*$)', result) return m.groups()[1]...

Translate url regex pattern for django internationalization

django,django-i18n

I think your msgid and msgstr are wrong here: msgid "r^help/" msgstr "r^ayuda/" you've mistakenly included the r in front, but this is not actually part of the string of the url pattern... notice that in the url pattern it is r"^help/" ...the r prefix tells Python this is a...