Language support!

This commit is contained in:
Martin Mahner 2014-10-28 11:22:43 +01:00
parent 030556ea05
commit ea27bf9e0f
8 changed files with 47 additions and 20 deletions

View file

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: dpaste\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-25 10:06+0000\n"
"PO-Revision-Date: 2014-10-25 12:07+0100\n"
"PO-Revision-Date: 2014-10-28 11:20+0100\n"
"Last-Translator: Martin Mahner <martin@mahner.org>\n"
"Language-Team: DE <LL@li.org>\n"
"Language: de\n"
@ -219,7 +219,7 @@ msgid ""
"No snippets saved. Either all your snippets are expired or your cookie has "
"changed."
msgstr ""
"Keine Snippets gespeichert. Entweder alle deine Snippets sind erloschen oder "
"Keine Snippets gespeichert. Entweder sind alle deine Snippets erloschen oder "
"dein Cookie hat sich geändert."
#, fuzzy

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,6 +1,25 @@
# Import global settings to make it easier to extend settings.
from django.conf.global_settings import *
#==============================================================================
# Calculation of directories relative to the module location
#==============================================================================
import os
import sys
import dpaste
PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split(
os.path.dirname(os.path.realpath(dpaste.__file__))
)
# Set the variable root to $VIRTUALENV/var.
PYTHON_BIN = os.path.dirname(sys.executable)
VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var')
if not os.path.exists(VAR_ROOT):
os.mkdir(VAR_ROOT)
#==============================================================================
# Generic Django project settings
#==============================================================================
@ -30,32 +49,21 @@ SECRET_KEY = 'CHANGE_ME'
# I18N
#==============================================================================
USE_I18N = False
USE_I18N = True
USE_L10N = False
LANGUAGE_CODE = 'en'
LANGUAGES = (
('en', 'English'),
('de', 'German'),
('es', 'Spanish'),
('pt-br', 'Portugese (Brasil)'),
)
#==============================================================================
# Calculation of directories relative to the module location
#==============================================================================
import os
import sys
import dpaste
PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split(
os.path.dirname(os.path.realpath(dpaste.__file__))
LOCALE_PATHS = (
os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'locale')),
)
# Set the variable root to $VIRTUALENV/var.
PYTHON_BIN = os.path.dirname(sys.executable)
VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var')
if not os.path.exists(VAR_ROOT):
os.mkdir(VAR_ROOT)
#==============================================================================
# Static files
#==============================================================================
@ -84,13 +92,15 @@ LOGIN_REDIRECT_URL = '/'
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
'django.core.context_processors.i18n',
)
INSTALLED_APPS = (

View file

@ -17,6 +17,21 @@
<a href="https://github.com/bartTC/dpaste">github.com/bartTC/dpaste</a>
</p>
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
Change the language:
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language">
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>
<h3>API</h3>
<p>dpaste provides a simple API documented in detail <a href="http://dpaste.readthedocs.org/en/latest/api.html">

View file

@ -4,6 +4,8 @@ urlpatterns = patterns(
'',
url(r'^', include('dpaste.urls.dpaste_api')),
url(r'^', include('dpaste.urls.dpaste')),
(r'^i18n/', include('django.conf.urls.i18n')),
)
# Custom error handlers which load `dpaste/<code>.html` instead of `<code>.html`