django-i18n

how to have unicode characters in django url?

半世苍凉 提交于 2019-12-02 10:53:01
My Url conf is as follows url(ur'^phrase/(?P<lang>[_A-Za-z]+)/(?P<phrase>[%A-Za-z0-9]+)/$', 'gs.langdb.views.phrases'), Views.phrases returns JSON object def phrases(request,lang,phrase): langs = Langauges.objects.all().values( 'language', 'lang_code') lang_list = [] try: map(lambda x: lang_list.append(x),langs) json = simplejson.dumps(lang_list) return HttpResponse(json, mimetype='application/json') except TypeError: print "Can't convert language to Json \n" My View is as follows:- $("#phrase").autocomplete({ source: function(request,response){ var selectedValue = document.getElementById(

How can I join lazy translation in Django?

我的梦境 提交于 2019-12-02 00:21:45
问题 I need to use lazy translation but also I need to make translation - how to deal with? This code is doing what I need: print ugettext_lazy('Hello world!') Now I want join two lazy translations together and translate it separately (I now that will not work and why but want to have two translation strings). print ugettext_lazy('Hello world!') + ' ' + ugettext_lazy('Have a fun!') I can do such code but it generates more translation than is need. print ugettext_lazy('Hello world! Have a fun!') Is

How to install GNU gettext on windows 7?

故事扮演 提交于 2019-11-30 04:54:05
I need to install version 0.15 or higher of GNU's gettext so that I can use some i18n feateres with django. I've downloaded : http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.3.1.tar.gz from https://www.gnu.org/software/gettext/ However I have no idea how to install it and there's no installation guide on their website. How can I install it ? I'm maintaining a GitHub repository with Windows binaries of gettext and iconv (I just updated it to the latest gettext version: 0.19.3) You can find it here: http://mlocati.github.io/gettext-iconv-windows/ To see how I compiled them (if you want to do it

Django internationalization language codes [closed]

你。 提交于 2019-11-28 18:39:01
Where can I find list of languages and language_code like this. (Swedish,sv) (English,en) Wiki: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes Thomas If you want something you can use from within django, try: from django.conf import settings this will be in the format above, making it perfect for assignment in one of your models choices= fields. (i.e. user_language = models.CharField(max_length=7, choices=settings.LANGUAGES) ) LANGUAGES = ( ('ar', gettext_noop('Arabic')), ('bg', gettext_noop('Bulgarian')), ('bn', gettext_noop('Bengali')), etc.... ) Note about using settings: Note that

Issue trying to change language from Django template

可紊 提交于 2019-11-27 12:31:30
I need to include two buttons or links to allow users change language between English and Spanish. I've read the docs and tried this: <form action="/i18n/setlang/" method="post">{% csrf_token %} <input name="language" type="hidden" value="es" /> <input type="submit" value="ES" /> </form> However, every time I click the button, the page is reloaded but the language doesn't change at all. Am I missing something? Note: I haven't set next , as I just want to reload the current page in the desired language. If I use the default form provided by the docs the result is the same: the page reloads but

Issue trying to change language from Django template

孤街醉人 提交于 2019-11-26 16:02:36
问题 I need to include two buttons or links to allow users change language between English and Spanish. I've read the docs and tried this: <form action="/i18n/setlang/" method="post">{% csrf_token %} <input name="language" type="hidden" value="es" /> <input type="submit" value="ES" /> </form> However, every time I click the button, the page is reloaded but the language doesn't change at all. Am I missing something? Note: I haven't set next , as I just want to reload the current page in the desired

What&#39;s the correct way to set up Django translation?

柔情痞子 提交于 2019-11-26 15:48:15
问题 I've got an issue with translations not working on Django 1.6. I've added this to my settings.py: LANGUAGE_CODE = 'en-us' ugettext = lambda s: s LANGUAGES = ( ('en', ugettext('English')), ('de', ugettext('German')), ) Also added middlewares: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages