Initial Multi Language Support
From this change onward all strings must tagged with oslo_i18n translate tag. Welcome multi language support and do not forget to tag missing strings. Change-Id: I9c59b2c91a31cb92abe1f0cb092efd611b300dfa
This commit is contained in:
parent
34af7eadf4
commit
29cbae8ff7
@ -1,22 +1,23 @@
|
||||
import re
|
||||
from oslo_i18n import translate as _
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from django import forms
|
||||
|
||||
class UserRegisterForm(forms.Form):
|
||||
email = forms.EmailField(label='Email')
|
||||
email = forms.EmailField(label=_('Email'))
|
||||
password1 = forms.CharField(
|
||||
label='Password',
|
||||
label=_('Password'),
|
||||
widget=forms.PasswordInput(),
|
||||
)
|
||||
password2 = forms.CharField(
|
||||
label='Password (Again)',
|
||||
label=_('Password (Again)'),
|
||||
widget=forms.PasswordInput(),
|
||||
)
|
||||
tos = forms.BooleanField(
|
||||
required=True,
|
||||
error_messages={'required': 'You must accept TOS.'}
|
||||
error_messages={'required': _('You must accept TOS.')}
|
||||
)
|
||||
|
||||
def clean_email(self):
|
||||
@ -25,7 +26,7 @@ class UserRegisterForm(forms.Form):
|
||||
User.objects.get(email=email)
|
||||
except ObjectDoesNotExist:
|
||||
return email
|
||||
raise forms.ValidationError('Email address is not available.')
|
||||
raise forms.ValidationError(_('Email address is not available.'))
|
||||
|
||||
def clean_password2(self):
|
||||
if 'password1' in self.cleaned_data:
|
||||
@ -33,4 +34,4 @@ class UserRegisterForm(forms.Form):
|
||||
password2 = self.cleaned_data['password2']
|
||||
if password1 == password2:
|
||||
return password2
|
||||
raise forms.ValidationError('Password do not match.')
|
||||
raise forms.ValidationError(_('Password do not match.'))
|
||||
|
@ -1,5 +1,7 @@
|
||||
import random, hashlib, datetime
|
||||
|
||||
from oslo_i18n import translate as _
|
||||
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
@ -27,6 +29,7 @@ def send_email(con,subject,email_to,email_from):
|
||||
def index(request):
|
||||
return render(request, "authcp/index.html", {})
|
||||
|
||||
# user registration
|
||||
def register_user(request):
|
||||
if request.method == 'POST':
|
||||
form = UserRegisterForm(request.POST)
|
||||
@ -46,7 +49,7 @@ def register_user(request):
|
||||
"%Y-%m-%d %H:%M:%S")
|
||||
profile.save()
|
||||
send_email({'u': u, 'profil': profile},
|
||||
'Welcome to our cloud',
|
||||
_('Welcome to our cloud'),
|
||||
u.email,
|
||||
settings.DEFAULT_EMAIL_FROM,
|
||||
)
|
||||
@ -59,9 +62,11 @@ def register_user(request):
|
||||
form = UserRegisterForm()
|
||||
return render(request, 'authcp/register.html', {'form': form})
|
||||
|
||||
# user registration success page
|
||||
def register_success(request):
|
||||
return render(request, 'authcp/success.html', {})
|
||||
|
||||
# user activation
|
||||
def activation(request, key):
|
||||
activation_expired=False
|
||||
already_active=False
|
||||
|
@ -12,7 +12,7 @@ _ = _translators.primary
|
||||
# The contextual translation function using the name "_C"
|
||||
# requires oslo.i18n >=2.1.0
|
||||
_C = _translators.contextual_form
|
||||
ya
|
||||
|
||||
# The plural translation function using the name "_P"
|
||||
# requires oslo.i18n >=2.1.0
|
||||
_P = _translators.plural_form
|
||||
|
43
locale/tr/LC_MESSAGES/django.po
Normal file
43
locale/tr/LC_MESSAGES/django.po
Normal file
@ -0,0 +1,43 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-02-05 21:41+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"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: authcp/forms.py:9
|
||||
msgid "Email"
|
||||
msgstr ""
|
||||
|
||||
#: authcp/forms.py:11
|
||||
msgid "Password"
|
||||
msgstr ""
|
||||
|
||||
#: authcp/forms.py:15
|
||||
msgid "Password (Again)"
|
||||
msgstr ""
|
||||
|
||||
#: authcp/forms.py:20
|
||||
msgid "You must accept TOS."
|
||||
msgstr ""
|
||||
|
||||
#: authcp/forms.py:29
|
||||
msgid "Email address is not available."
|
||||
msgstr ""
|
||||
|
||||
#: authcp/forms.py:37
|
||||
msgid "Password do not match."
|
||||
msgstr ""
|
Loading…
x
Reference in New Issue
Block a user