Skip to content

Commit

Permalink
Added known locales list. Added LANG and DIR to the context.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Wenzel committed Jan 6, 2011
1 parent c286693 commit 4be0ae8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
Empty file added apps/commons/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions apps/commons/context_processors.py
@@ -0,0 +1,10 @@
from django.conf import settings
from django.utils import translation


def i18n(request):
return {'LANGUAGES': settings.LANGUAGES,
'LANG': settings.LANGUAGE_URL_MAP.get(translation.get_language())
or translation.get_language(),
'DIR': 'rtl' if translation.get_language_bidi() else 'ltr',
}
Empty file added apps/commons/models.py
Empty file.
30 changes: 21 additions & 9 deletions settings.py
Expand Up @@ -17,6 +17,9 @@

DATABASES = {} # See settings_local.

# Site ID is used by Django's Sites framework.
SITE_ID = 1


## Internationalization.

Expand All @@ -29,12 +32,6 @@
# system time zone.
TIME_ZONE = 'America/Los_Angeles'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-US'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
Expand All @@ -43,6 +40,18 @@
# calendars according to the current locale
USE_L10N = True

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-US'

# List of locales known to this project.
LANGUAGES = ('en-US',)

# List of RTL locales known to this project. Subset of LANGUAGES.
RTL_LANGUAGES = () # ('ar', 'fa', 'fa-IR', 'he')

LANGUAGE_URL_MAP = dict([(i.lower(), i) for i in LANGUAGES])


## Media and templates.

Expand Down Expand Up @@ -78,6 +87,7 @@
'django.core.context_processors.csrf',
'django.contrib.messages.context_processors.messages',

'commons.context_processors.i18n',
#'jingo_minify.helpers.build_ids',
)

Expand Down Expand Up @@ -138,8 +148,6 @@ def JINJA_CONFIG():
'django.contrib.auth',
'django_sha2', # Load after auth to monkey-patch it.
'django.contrib.contenttypes',
'jingo_minify',
'tower', # for ./manage.py extract (L10n)

# 'django.contrib.sessions',
# 'django.contrib.sites',
Expand All @@ -149,7 +157,11 @@ def JINJA_CONFIG():
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',

'examples',
'commons', # Content common to most playdoh-based apps.
'jingo_minify',
'tower', # for ./manage.py extract (L10n)

'examples', # Example code. Can (and should) be removed for actual projects.
)

# Tells the extract script what files to look for L10n in and what function
Expand Down
2 changes: 1 addition & 1 deletion templates/example_base.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html LANG="{{ LANG }}" dir="{{ DIR }}">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>{% block page_title %}playdoh examples{% endblock %}</title>
Expand Down

0 comments on commit 4be0ae8

Please sign in to comment.