django-i18n

How do I explicitly specify language of email I want to send?

倾然丶 夕夏残阳落幕 提交于 2021-01-27 13:17:23
问题 I have a custom user model that have a preferred_language field. I want all the emails (activation and password reset) to be sent translated to the language that user specified in profile. class CustomUser(AbstractBaseUser, PermissionsMixin): ... LANGUAGE_CHOICES = ( (1, "English"), (2, "Русский") ) preferred_language = models.PositiveSmallIntegerField(choices=LANGUAGE_CHOICES, default=2, verbose_name=_("Preferred language")) I thought about setting custom email class but didn't saw in navive

Set language of PasswordResetForm in Django?

限于喜欢 提交于 2020-06-27 04:07:23
问题 I am manually resetting passwords but wonder how to set the language to the user's language instead of my own. I see there are many extra context fields but which one needs to be set? for user in qs: reset_form = PasswordResetForm({'email': user.email}) # reset_form.language? assert reset_form.is_valid() reset_form.save(request=request) I have added a field CustomUser.language which would be available in user.language above. (While phrasing my question and looking for possibilities I found a

Django- invalid token in plural form: EXPRESSION

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-25 04:47:45
问题 I added 'Kurdish' language to my django website. this language is not supported by django, so I added to languages as follow: in settings.py gettext = lambda s: s NEW_LANG_INFO = { 'ku': { 'bidi': True, 'code': 'ku', 'name': 'Kurdish', 'name_local': u'کوردی', }, } import django.conf.locale LANG_INFO = dict(**django.conf.locale.LANG_INFO, **NEW_LANG_INFO) django.conf.locale.LANG_INFO = LANG_INFO LANGUAGES = ( ('en', 'English'), ('ku', gettext('Kurdish')), ('ar', 'Arabic') ) now when i go to

how to have unicode characters in django url?

笑着哭i 提交于 2020-01-22 02:31:07
问题 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:- $("

How to maintain different country versions of same language in Django?

巧了我就是萌 提交于 2020-01-12 06:56:29
问题 I would like to have a few different versions of the same language in Django, customized for different countries (e.g. locale/en , locale/en_CA , locale/en_US , etc.). If there is no language for specific country I would expect to use the default language version ( locale/en )). Then in the settings file for each site I specify LANGUAGE_CODE and LANGUAGES . For some reason, even if I specify the following settings, the locale/en_US translations are still used: LANGUAGE_CODE = 'en' LANGUAGES =

Django's get_current_language strange behavior

非 Y 不嫁゛ 提交于 2020-01-06 04:30:45
问题 I want to set the lang attribute in my html tag to the current locale's language based on the language defined in my settings.py. I don't use the LocaleMiddleware and the user can not choose the language. (I have different domain's for the same page. If someone want's to see the website in a different language, the user has to go to a different website ) settings.py LANGUAGE_CODE = 'pl-PL' USE_I18N = True USE_L10N = True LANGUAGES = [ ('en', 'English'), ('de', 'German'), ('pl', 'Polish'), (

Collecting messages from 3rd party apps in Django

五迷三道 提交于 2020-01-01 10:58:32
问题 How can I generate messages (manage.py makemessages) from 3rd party library which is located in virtualenv directory? I tried simply add the messages to the .po file, but everytime I run makemessages command my translation vanishes. Many thanks 回答1: manage.py makemessages looks only for directories under the current dir. So you have to create symlink from 3rd party app to your project's directory: ln -s ~/.virtualenvs/myvenv/local/lib/python2.7/site-packages/app app mkdir locale python manage

Collecting messages from 3rd party apps in Django

杀马特。学长 韩版系。学妹 提交于 2020-01-01 10:58:28
问题 How can I generate messages (manage.py makemessages) from 3rd party library which is located in virtualenv directory? I tried simply add the messages to the .po file, but everytime I run makemessages command my translation vanishes. Many thanks 回答1: manage.py makemessages looks only for directories under the current dir. So you have to create symlink from 3rd party app to your project's directory: ln -s ~/.virtualenvs/myvenv/local/lib/python2.7/site-packages/app app mkdir locale python manage

How to install GNU gettext on windows 7?

时间秒杀一切 提交于 2019-12-30 01:08:11
问题 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 ? 回答1: 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

Django internationalization language codes [closed]

主宰稳场 提交于 2019-12-17 22:22:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Where can I find list of languages and language_code like this. (Swedish,sv) (English,en) 回答1: Wiki: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 回答2: 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