Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (73 sloc) 3.437 kb
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
1 ####################
c785e80 @cortextual some documentation improvements, including
cortextual authored
2 Internationalization
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
3 ####################
ae014e2 i18n docs added
divio authored
4
a919c2c @digi604 i18n docs
digi604 authored
5
86fd1a1 @digi604 docs
digi604 authored
6 *****************
7 Multilingual URLs
8 *****************
ae014e2 i18n docs added
divio authored
9
5507637 @digi604 resolved some inputs from fellow devs
digi604 authored
10 If you use more than one language, django CMS urls need
11 to be referenced via :func:`~django.conf.urls.i18n.i18n_patterns`. For more information about this see the
12 official django `documentation`_.
ae014e2 i18n docs added
divio authored
13
237609f @digi604 missed one
digi604 authored
14 Main `urls.py` example::
ae014e2 i18n docs added
divio authored
15
86fd1a1 @digi604 docs
digi604 authored
16 from django.conf import settings
17 from django.conf.urls.defaults import patterns, include, url
18 from django.contrib import admin
19 from django.conf.urls.i18n import i18n_patterns
20 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
ae014e2 i18n docs added
divio authored
21
86fd1a1 @digi604 docs
digi604 authored
22 admin.autodiscover()
ae014e2 i18n docs added
divio authored
23
86fd1a1 @digi604 docs
digi604 authored
24 urlpatterns = patterns('',
25 url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
26 )
a541a63 @fivethreeo note on middleware ordering
fivethreeo authored
27
86fd1a1 @digi604 docs
digi604 authored
28 urlpatterns += staticfiles_urlpatterns()
a541a63 @fivethreeo note on middleware ordering
fivethreeo authored
29
86fd1a1 @digi604 docs
digi604 authored
30 urlpatterns += i18n_patterns('',
31 url(r'^admin/', include(admin.site.urls)),
32 url(r'^', include('cms.urls')), # <--------- include the django cms urls via i18n_patterns
33 )
a541a63 @fivethreeo note on middleware ordering
fivethreeo authored
34
86fd1a1 @digi604 docs
digi604 authored
35
5507637 @digi604 resolved some inputs from fellow devs
digi604 authored
36 .. _documentation: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#internationalization-in-url-patterns
a541a63 @fivethreeo note on middleware ordering
fivethreeo authored
37
c34025f @digi604 cookie middleware added
digi604 authored
38 ***************
39 Language Cookie
40 ***************
41
42 By default if someone visits a page at `http://www.mysite.fr/` django determines the language as follow:
43
44 - language in url
45 - language in session
46 - language in cookie
47 - language in from browser
48 - LANGUAGE_CODE from settings
49
50 No if i have a German browser and visit a page that is only English and French, it will choose the language that is
51 in LANGUAGE_CODE. If this is English but i only speak French i have to switch the language. No if after sometime
52 i visit the page again. The page will display in English again and I have to switch again. The same is for every
53 link that points to `/` will switch to English again. To fix this behavior the cms ships with a middleware:
54
55 `cms.middleware.language.LanguageCookieMiddleware`
56
57 add this to you middleware settings fix this.
58
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
59 ****************
ae014e2 i18n docs added
divio authored
60 Language Chooser
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
61 ****************
ae014e2 i18n docs added
divio authored
62
6768cea @piquadrat added more sphinx refs, fixed a couple of typos, enabled intersphinx (ya...
piquadrat authored
63 The :ttag:`language_chooser` template tag will display a language chooser for the
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
64 current page. You can modify the template in ``menu/language_chooser.html`` or
65 provide your own template if necessary.
ae014e2 i18n docs added
divio authored
66
051d990 @ojii Docs improvements (highlighting, typos, ...)
ojii authored
67 Example:
68
69 .. code-block:: html+django
ae014e2 i18n docs added
divio authored
70
4a37654 @jsma Replaced tabs => 4-spaces in docs for consistency as alternating tabs/sp...
jsma authored
71 {% load menu_tags %}
72 {% language_chooser "myapp/language_chooser.html" %}
ae014e2 i18n docs added
divio authored
73
cf964bc @ojii Added simple_language_changer documentation
ojii authored
74
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
75 *****************
6b66d15 @digi604 docs converted to sphinx
digi604 authored
76 page_language_url
ebbc566 @ojii Changed documentation section styles to be consistent (and to the sectio...
ojii authored
77 *****************
ae014e2 i18n docs added
divio authored
78
6768cea @piquadrat added more sphinx refs, fixed a couple of typos, enabled intersphinx (ya...
piquadrat authored
79 This template tag returns the URL of the current page in another language.
ae014e2 i18n docs added
divio authored
80
6768cea @piquadrat added more sphinx refs, fixed a couple of typos, enabled intersphinx (ya...
piquadrat authored
81 Example:
82
83 .. code-block:: html+django
ae014e2 i18n docs added
divio authored
84
4a37654 @jsma Replaced tabs => 4-spaces in docs for consistency as alternating tabs/sp...
jsma authored
85 {% page_language_url "de" %}
86
87
fedc753 @digi604 docs
digi604 authored
88 ******************
89 hide_unstranslated
90 ******************
a919c2c @digi604 i18n docs
digi604 authored
91
fedc753 @digi604 docs
digi604 authored
92 If you add a default directive to your :setting:`CMS_LANGUAGES` with a :setting:`hide_unstranslated` to ``False``
93 all pages will be displayed in all languages even if they are
6768cea @piquadrat added more sphinx refs, fixed a couple of typos, enabled intersphinx (ya...
piquadrat authored
94 not translated yet.
a919c2c @digi604 i18n docs
digi604 authored
95
fedc753 @digi604 docs
digi604 authored
96 If `hide_untranslated` is ``True`` in your :setting:`CMS_LANGUAGES`
4cff319 @rasca Fixed #1348 corrected page_language_url on non CMS managed urls
rasca authored
97 and you are on a page that doesn't yet have an English translation and you view
98 the German version then the language chooser will redirect to ``/``. The same
99 goes for urls that are not handled by the cms and display a language chooser.
8c20c5c @digi604 Merge pull request #1348 from rasca/issue1348
digi604 authored
100
581c87e @ojii Updated unihandecode dependency to 1.0.0
ojii authored
101 ********************************************
102 Automated slug generation unicode characters
103 ********************************************
10d462a @ojii Added support for unihandecode.js
ojii authored
104
105 If your site has languages which use non-ASCII character sets, you might want
581c87e @ojii Updated unihandecode dependency to 1.0.0
ojii authored
106 to enable :setting:`CMS_UNIHANDECODE_HOST` and :setting:`CMS_UNIHANDECODE_VERSION`
107 to get automated slugs for those languages too.
c34025f @digi604 cookie middleware added
digi604 authored
108
109
Something went wrong with that request. Please try again.