Django: Deutsche Übersetzungen mit i18n

Django, Flask, Bottle, WSGI, CGI…
Antworten
ready
User
Beiträge: 33
Registriert: Sonntag 15. Juni 2008, 12:21
Kontaktdaten:

Hallo Leute,

folgendes: ich verwende seit gestern für mein Django Projekt (Einen Webshop) die django app: django-pagination um damit Datensätze zu paginieren. Das funktioniert soweit auch ganz gut. Es gibt da natürlich eine Zeile wo man die Seiten wechseln kann. Dort steht:
‹‹ previous 1 2 3 4 5 next ››
also in englisch: previous und next
Nun möchte ich natürlich dass es dort in deutsch steht: Zurück und Weiter.
Ich habe mir die app django-pagination mal genauer angesehen. Im Template wird an dieser Stelle folgendes verwendet:

Code: Alles auswählen

{% load i18n %}
{% trans "previous" %}
{% trans "next" %}
Außerdem gibts ein Verzeichnis: locale/de/LC_MESSAGES
und eine Datei: django.po wo folgendes drin steht:

Code: Alles auswählen

#: templates/pagination/pagination.html:5
#: templates/pagination/pagination.html:7
msgid "previous"
msgstr "Zurück"

#: templates/pagination/pagination.html:21
#: templates/pagination/pagination.html:23
msgid "next"
msgstr "Weiter"
in meiner settings.py steht drin:
LANGUAGE_CODE = 'de'

also müsste er doch jetzt eigentlich "Zurück" und "Weiter" anzeigen.
Warum tut er das aber nicht?

Vielen Dank
MfG ready
ready
User
Beiträge: 33
Registriert: Sonntag 15. Juni 2008, 12:21
Kontaktdaten:

Hat wirklich niemand Ahnung von der Thematik? Es muss doch schonmal einer was mit i18n gemacht haben :K
Gruß ready
apollo13
User
Beiträge: 827
Registriert: Samstag 5. Februar 2005, 17:53

Naja po Dateien sind uninteressant, existieren passend dazu mo Dateien? Wie schauen deine Settings aus?
ready
User
Beiträge: 33
Registriert: Sonntag 15. Juni 2008, 12:21
Kontaktdaten:

Ahh apollo13, wie immer, der retter meiner Threads :)
apollo13 hat geschrieben:Naja po Dateien sind uninteressant, existieren passend dazu mo Dateien?
Ja existieren, hier der Inhalt:

Code: Alles auswählen

��
Report-Msgid-Bugs-To: 
POT-Creation-Date: 2009-03-16 16:26+0100
PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
Last-Translator: FULL NAME <EMAIL@ADDRESS>
Language-Team: LANGUAGE <LL@li.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
apollo13 hat geschrieben:Wie schauen deine Settings aus?
Interessiert dich jetzt ein bestimmtes Setting oder möchtest du, dass ich die ganze settings.py poste? (Gross!)

Danke =)
und MfG ready
apollo13
User
Beiträge: 827
Registriert: Samstag 5. Februar 2005, 17:53

INSTALLED_APPS und alles was mit Sprace, Lokalisierung und Internationalisierung zu tun hat. Aber du kannst gerne die komplette settings.py posten, ich find mich mit CTRL+F auch zurecht *gg*

Btw jag mal ein manage.py compilemessages drüber, nicht dass die mo dateien die Übersetzung noch nicht enthalten.
ready
User
Beiträge: 33
Registriert: Sonntag 15. Juni 2008, 12:21
Kontaktdaten:

Hi apollo13 :)
apollo13 hat geschrieben:INSTALLED_APPS und alles was mit Sprace, Lokalisierung und Internationalisierung zu tun hat. Aber du kannst gerne die komplette settings.py posten, ich find mich mit CTRL+F auch zurecht *gg*
Hier die settings.py - Ein paar Einträge hab ich allerdings durch xxxx ersetzt ;)
Django Version verwende ich übrigends 1.3

Code: Alles auswählen

#! /usr/bin/env python
# emacs-mode: -*- python-*-
# -*- coding: utf-8 -*-

from os.path import join
import os

DEBUG = True
LOGGING_OUTPUT_ENABLED = True
LOGGING_LOG_SQL = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (('haka', 'haka@xxxxx))
MANAGERS = ADMINS
PROJECT_PATH = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]
SYSTEM = "one"
DOMAIN = "django:9900"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'HOST': '',
        'NAME': '%s/db.sqlite' % PROJECT_PATH,
        'PORT': '',
        'USER': '',
        'PASSWORD': ''
    }
}

TIME_ZONE = 'Europe/Berlin'
LANGUAGE_CODE = 'de'
#INTERNAL_IPS = ('172.26.1.23', '127.0.0.1', '0.0.0.0')
INTERNAL_IPS = ('172.20.1.197', '172.26.1.23', '127.0.0.1', '0.0.0.0')

SITE_ID = 1
USE_I18N = True
PROJECT_ROOT = '/home/ready/Development/Workspaces/Parkettmonitor/parkettmonitor/'
MEDIA_ROOT = '/home/ready/Development/Workspaces/Parkettmonitor/parkettmonitor/media'
#MEDIA_URL = 'http://django/media/'
MEDIA_URL = '/'
LOGIN_URL = '/user/login/'
ADMIN_MEDIA_PREFIX = '/media/'
SECRET_KEY = 'xxxxx'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader'
)
TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    #"django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",
    "django.core.context_processors.request"
)
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.doc.XViewMiddleware',
    'pagination.middleware.PaginationMiddleware',
    'pm.middleware.ActiveUserMiddleware',
    #'djangologging.middleware.LoggingMiddleware',
    #'djangologging.middleware.SuppressLoggingOnAjaxRequestsMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware',
)
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'default-cache'
    }
}
ROOT_URLCONF = 'pm.urls'
TEMPLATE_DIRS = (join(PROJECT_ROOT, 'pm/html'))
INSTALLED_APPS = (
    'django.contrib.admindocs',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'pm.util',
    'pm.shop',
    'pm.news',
    'pm.user',
    'pm.philosophy',
    'pm.testing',
    'pm.impressions',
    'pm.adminpanel',
    'photologue',
    'tagging',
    'pagination'
)
LOGFILE = join(PROJECT_ROOT, 'django.log')

# e-mail settings
DEFAULT_FROM_EMAIL = 'registrierung@xxxxx'
EMAIL_ENABLED = True

EMAIL_HOST = 'mail.ligno.com'
EMAIL_HOST_USER = 'mailuser'
EMAIL_HOST_PASSWORD = ''
AUTH_PROFILE_MODULE = 'user.Profile'
ACCOUNT_ACTIVATION_DAYS = 30

#LOGGING_OUTPUT_ENABLED = True
LOGIN_URL = '/user/login'
LOGOUT_URL = '/user/logout'

# APPLICATION SETTINGS
#ADMIN_MAILS = ['haka@xxxxx', 'hoka@xxxxx']
ADMIN_MAILS = ['haka@xxxxx']
SMTP_USER = "ready" 
SMTP_PASSWORD = "xxxxx"
SMTP_HOST = "mail.sitea.cc"

# Number of seconds of inactivity before a user is marked offline
USER_ONLINE_TIMEOUT = 60 * 30

# Number of seconds that we will keep track of inactive users for before 
# their last seen is removed from the cache
USER_LASTSEEN_TIMEOUT = 60 * 60 * 24 * 7

# Media paths
MEDIA_PATHS = ['/js','/css','/img','/dojango','/Parkettimpressionen','/photologue']
apollo13 hat geschrieben:Btw jag mal ein manage.py compilemessages drüber, nicht dass die mo dateien die Übersetzung noch nicht enthalten.
Hab ich gemacht:

Code: Alles auswählen

ready@one:~/Development/Workspaces/Parkettmonitor/parkettmonitor/external/pagination$ python ../../pm/manage.py compilemessages
processing file django.po in /data/root/home/ready/Development/Workspaces/Parkettmonitor/parkettmonitor/external/pagination/locale/de/LC_MESSAGES
processing file django.po in /data/root/home/ready/Development/Workspaces/Parkettmonitor/parkettmonitor/external/pagination/locale/fr/LC_MESSAGES
processing file django.po in /data/root/home/ready/Development/Workspaces/Parkettmonitor/parkettmonitor/external/pagination/locale/pl/LC_MESSAGES
processing file django.po in /data/root/home/ready/Development/Workspaces/Parkettmonitor/parkettmonitor/external/pagination/locale/pt/LC_MESSAGES
Der inhalt der .mo Dateien ist danach genau der Gleiche wie zuvor. Und es werden auch noch die englischen bezeichnungen angezeigt -> funzt also nicht.


Danke
MfG ready
Antworten