Now passing user's language to celery task

This commit is contained in:
PCoder 2017-09-16 20:55:37 +05:30
parent acb739944b
commit 0cf8e237b5
3 changed files with 22 additions and 2 deletions

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-03 16:44+0000\n"
"POT-Creation-Date: 2017-09-16 14:09+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -18,6 +18,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#, python-format
msgid "Your New VM %(vm_name)s at Data Center Light"
msgstr "Deine neue VM %(vm_name)s bei Data Center Light"
msgid "Enter name"
msgstr "Name"
@ -183,9 +187,18 @@ msgstr "Kontakt"
msgid "All Rights Reserved"
msgstr "Alle Rechte vorbehalten"
msgid "Toggle navigation"
msgstr "Konfiguration"
msgid "Why Data Center Light?"
msgstr "Warum Data Center Light?"
msgid "Login"
msgstr ""
msgid "Dashboard"
msgstr ""
msgid "Finally, an affordable VM hosting in Switzerland!"
msgstr "Endlich: bezahlbares VM Hosting in der Schweiz"

View file

@ -5,6 +5,7 @@ from celery.utils.log import get_task_logger
from celery import current_task
from django.conf import settings
from django.core.mail import EmailMessage
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from dynamicweb.celery import app
@ -141,6 +142,11 @@ def create_vm_task(self, vm_template_id, user, specs, template,
email.send()
if 'pass' in user:
lang = 'en-us'
if user.get('language') is not None:
logger.debug("Language is set to {}".format(user.get('language')))
lang = user.get('language')
translation.activate(lang)
# Send notification to the user as soon as VM has been booked
context = {
'vm': vm,

View file

@ -14,7 +14,7 @@ from django.shortcuts import redirect
from django.shortcuts import render
from django.utils.http import urlsafe_base64_decode
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import get_language, ugettext_lazy as _
from django.views.generic import View, CreateView, FormView, ListView, \
DetailView, \
DeleteView, TemplateView, UpdateView
@ -757,6 +757,7 @@ class OrdersHostingDetailView(LoginRequiredMixin,
'pass': self.request.user.password,
'request_scheme': request.scheme,
'request_host': request.get_host(),
'language': get_language(),
}
create_vm_task.delay(vm_template_id, user, specs, template,
stripe_customer_id, billing_address_data,