Answer the question
In order to leave comments, you need to log in
How to implement multilingual interface with Django?
Hello, oh great uncles. I need your help. How to implement multilingual interface with Django? I have my own idea, but more than once in other languages I faced the fact that I reinvented the wheel again. Decided to laugh. I've only been studying Django for 5 days. Now, if that's an idea:
There is some kind of page, a view, but in a separate application. Well, for example, there are many of these pages. They are all separate and independent.
And for multilingualism, I created a new APP named Languages. Inside created a new 'language.py'
RU={
'main_title':'Главная',
'lang_panel_index':'Язык',
'reg_panel_index':'Регистрация',
'text_index':'Добро пожаловать в социальную сеть Dos',
'login_index':'Вход',
'about':'о проекте',
'advert':'реклама',
'dev':'разработчикам',
'contacts':'контакты',
'rools':'правила'
}
EN={
'main_title':'Main',
'lang_panel_index':'Language',
'reg_panel_index':'Registration',
'text_index':'Welcome to the Dos',
'login_index':'Enter',
'about':'about',
'advert':'advert',
'dev':'development',
'contacts':'contacts',
'rools':'rools'
}
KZ={
'main_title':'Басты',
'lang_panel_index':'Тілді тандау',
'reg_panel_index':'Тіркелу',
'text_index':'Dos интернет-бағдарламасына қош келдіңіздер',
'login_index':'Кіру',
'about':'жоба туралы',
'advert':'жарнама',
'dev':'дамытушыларға',
'contacts':'байланыс',
'rools':'ережелер'
}
class langpack(object):
def lang(l):
return {
'ru' : RU,
'en' : EN,
'kz' : KZ
}.get(l, "none")
from django.shortcuts import render_to_response
from languages.language import langpack
from django.contrib.sessions import *
default_lang='ru'
context=langpack.lang(default_lang)
def index(request):
response = render_to_response('index/index.html', context)
response.set_cookie('language',default_lang)
return response
# return render(request, 'index/index.html',context)
Answer the question
In order to leave comments, you need to log in
Well, there are built-in tools for localization. Read documentation. And install PyCharm, it's hard to work with Dzhanga in Sublim.
PS Advertising in Kazakh is translated as "zharnama".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question