Browse Source

Add language switching

devel
nerosketch 8 years ago
parent
commit
0c4155dd04
  1. 2
      accounts_app/templates/accounts/login.html
  2. 2
      clientsideapp/templates/clientsideapp/ext.html
  3. 4
      djing/settings.py
  4. 4
      djing/urls.py
  5. 3
      locale/ru/LC_MESSAGES/django.po
  6. 2
      mapapp/templates/maps/ya_index.html
  7. 2
      templates/403.html
  8. 2
      templates/404.html
  9. 17
      templates/all_base.html

2
accounts_app/templates/accounts/login.html

@ -1,5 +1,5 @@
<!DOCTYPE html>{% load i18n %} <!DOCTYPE html>{% load i18n %}
<html lang="ru">
<html lang="{{ LANGUAGE_CODE }}">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>{% trans 'Auth' %}</title> <title>{% trans 'Auth' %}</title>

2
clientsideapp/templates/clientsideapp/ext.html

@ -1,5 +1,5 @@
<!DOCTYPE HTML>{% load globaltags %}{% load i18n %} <!DOCTYPE HTML>{% load globaltags %}{% load i18n %}
<html lang="ru">
<html lang="{{ LANGUAGE_CODE }}">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">

4
djing/settings.py

@ -62,6 +62,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
@ -83,6 +84,7 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n',
'taskapp.context_proc.get_active_tasks_count', 'taskapp.context_proc.get_active_tasks_count',
'msg_app.context_processors.get_new_messages_count' 'msg_app.context_processors.get_new_messages_count'
], ],
@ -125,7 +127,7 @@ SESSION_COOKIE_HTTPONLY = True
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/ # https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'ru-RU'
LANGUAGE_CODE = 'ru'
LANGUAGES = [ LANGUAGES = [
('ru', _('Russian')), ('ru', _('Russian')),

4
djing/urls.py

@ -18,6 +18,10 @@ urlpatterns = [
url(r'^msg/', include('msg_app.urls', namespace='msg_app')), url(r'^msg/', include('msg_app.urls', namespace='msg_app')),
url(r'^dialing/', include('dialing_app.urls', namespace='dialapp')), url(r'^dialing/', include('dialing_app.urls', namespace='dialapp')),
url(r'^groups/', include('group_app.urls', namespace='group_app')), url(r'^groups/', include('group_app.urls', namespace='group_app')),
# Switch language
url(r'^i18n/', include('django.conf.urls.i18n')),
# url(r'^admin/', admin.site.urls) # url(r'^admin/', admin.site.urls)
] ]

3
locale/ru/LC_MESSAGES/django.po

@ -107,3 +107,6 @@ msgstr "Звонки"
#: templates/base.html:85 #: templates/base.html:85
msgid "Devices" msgid "Devices"
msgstr "Устройства" msgstr "Устройства"
msgid "Language"
msgstr "Язык"

2
mapapp/templates/maps/ya_index.html

@ -1,6 +1,6 @@
{% extends 'base_no_lmenu.html' %}{% load i18n %} {% extends 'base_no_lmenu.html' %}{% load i18n %}
{% block main %} {% block main %}
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
<script src="https://api-maps.yandex.ru/2.1/?lang={{ LANGUAGE_CODE }}" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
/* /*

2
templates/403.html

@ -1,6 +1,6 @@
<!DOCTYPE html>{% load i18n %} <!DOCTYPE html>{% load i18n %}
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head lang="ru">
<head lang="{{ LANGUAGE_CODE }}">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>{% trans 'Permission denied' %}</title> <title>{% trans 'Permission denied' %}</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">

2
templates/404.html

@ -9,7 +9,7 @@
{% else %} {% else %}
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head lang="ru">
<head lang="{{ LANGUAGE_CODE }}">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>{% trans 'Page does not exist' %}</title> <title>{% trans 'Page does not exist' %}</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">

17
templates/all_base.html

@ -1,5 +1,5 @@
<!DOCTYPE html>{% load globaltags %}{% load i18n %} <!DOCTYPE html>{% load globaltags %}{% load i18n %}
<html lang="ru_RU">
<html lang="{{ LANGUAGE_CODE }}">
<head> <head>
<title>{% global_var 'COMPANY_NAME' %} - {% trans 'Admin side' %}</title> <title>{% global_var 'COMPANY_NAME' %} - {% trans 'Admin side' %}</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
@ -51,6 +51,21 @@
<li{% if map_url == request.path %} class="active"{% endif %}><a href="{{ map_url }}" target="_blank">{% trans 'Map page' %}</a></li> <li{% if map_url == request.path %} class="active"{% endif %}><a href="{{ map_url }}" target="_blank">{% trans 'Map page' %}</a></li>
{% endif %} {% endif %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans 'Language' %} <b class="caret"></b></a>
<ul class="dropdown-menu">
{% url 'set_language' as set_language_url %}
{% for lang in LANGUAGES %}
<li><a href="#" id="langfrm_{{ lang.0 }}" onclick="document.setLang{{ lang.0 }}.submit();">{{ lang.1 }}</a></li>
<form name="setLang{{ lang.0}}" action="{{ set_language_url }}" method="POST" class="hidden">{% csrf_token %}
<input type="hidden" name="language" value="{{ lang.0 }}">
</form>
{% endfor %}
</ul>
</li>
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans 'Other' %} <b class="caret"></b></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans 'Other' %} <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">

Loading…
Cancel
Save