You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Clarify what needs to be done in TODOs
- Clean up Introduction
- Add labels
- Fix heading levels
- Fix MyST and English syntax and markup
- One sentence per line
- Verify GUI labels, add screenshots
Copy file name to clipboardExpand all lines: docs/i18n-l10n/language-negotiation.md
+62-20Lines changed: 62 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,49 +10,91 @@ html_meta:
10
10
11
11
# Language negotiation
12
12
13
-
```{note}
14
-
TODO: rework this section.
13
+
```{todo}
14
+
This section may contain incorrect information.
15
+
If you find errors, please submit a pull request to correct them.
15
16
```
16
17
17
18
```{admonition} Description
18
19
Accessing and changing the language state of Plone programmatically.
19
20
```
20
21
22
+
Language negotiation is a function of the HTTP protocol.
23
+
It lets a server choose among several language versions of a page based on the URL and preference information sent by the browser.
21
24
22
-
## Introduction
25
+
Plone uses specific rules to select the language in which the user interface is presented to the end user.
26
+
There are two distinct use cases: when `plone.app.multilingual` is not enabled and when it is.
23
27
24
-
Language negotiation is a function of the HTTP protocol which lets a server choose among several language versions of a page, based on the URL and on preference information sent by the browser.
25
28
26
-
Plone uses specific negotiation rules to negotiate the language in which provides the user interface to the end user. In any case, we have to distinguish two different cases here: when plone.app.multilingual is enabled and when not
When the referenced product is not installed but the Site Administrator configures multiple languages in Plone, Plone assumes that the user only wants to allow to change the user interface language.
33
+
When `plone.app.multilingual` is not installed, but the site administrator configures multiple languages in Plone, Plone only allows changing the language of the user interface.
34
+
This means that the language chooser links on the top of the page will only have effect for the user interface elements presented to the user.
35
+
These user interface elements may include search form options, editing interface messages, portal message statuses, and so on.
31
36
32
-
This means that the language change links on the top of the page will only have effect in the user interface presented to the user. For example: search form options, editing interface messages, portal message statuses, ...
37
+
By visiting the URI `@@language-controlpanel` ({guilabel}`Site Setup > General > Language`), the site administrator may configure language options for the site.
33
38
34
-
Going to the @@language-controlpanel the site administrator has multiple options with which can influence the working of the site.
By default, the {guilabel}`Always show language selector` option is not enabled, but it is required if the user wants to offer the language change in the interface.
35
55
36
-
For instance, by default the "Always show language selector" option is not enabled, but it is required if the user wants to offer the language change in the interface. Goingo to the "Negotiation scheme" in the same configuration page, the Site Administrator can influence how Plone will decide which language to present to each user.
56
+
By selecting the {guilabel}`Negotiation scheme` tab, the site administrator can configure how Plone will select a language to present to each user.
For instance, if the site is being presented in a subfolder with the language code (think of www.domain.com/en) or in subdomain (think of en.domain.com), Plone can be configured to take that subfolder or domain language code and select that language to present to the user.
62
+
For instance, if the site is being presented in a sub-folder (`www.domain.com/en`) or in a subdomain (`en.domain.com`), with either example using a language code such as `en`, then Plone can be configured to take that sub-folder or subdomain as the language code, and select that language to present to the user.
39
63
40
-
Another common configuration is to use the browser language request negotiation. This means that Plone relies on the `Accept-Language` HTTP header sent by the user browser (which previously can be configured to set the list of the wanted languages in rank of preference). For example a user can configure her browser to request pages in German (de), French (fr), and English (en). In such a case Plone will compare Plone's language list with the user requirements, and will decide in which language to present the site.
64
+
Another common configuration is to use the browser language request negotiation.
65
+
This means that Plone relies on the `Accept-Language` HTTP header sent by the user's browser.
66
+
The user can configure the list of languages to use in their preferred order, such as in German (de), French (fr), and English (en).
67
+
In this scenario, Plone will compare its language list with the user's preferences, and will determine in which language to present the site.
41
68
42
-
The exact working of each of the negotiation options is implemented in the `LanguageUtility` which lies in `plone.i18n.utility.py`.
69
+
The exact working of each of the negotiation options is implemented in the class [`LanguageUtility`](https://github.com/plone/plone.i18n/blob/fc05eb4c131574fd8a4353d5346e17866b3a5e2c/plone/i18n/utility.py#L73) in the module `utility.py`in the package `plone/plone.i18n`.
43
70
44
-
Plone also sets a language cookie with the language preference of the user. This cookie called `I18N_LANGUAGE` must be declared as a `Technical Cookie` and is a session cookie, which means that will be deleted after the user has leave the site. To obey the cookie the setting "Use cookie for manual override" should be set along with the "Set cookie for manual override".
71
+
Plone also sets a cookie with the language preference of the user.
72
+
This cookie is called `I18N_LANGUAGE`.
73
+
It must be declared as a "technical cookie".
74
+
It is a session cookie, which means that it will be deleted after the user leaves the site.
75
+
To obey the cookie the setting, {guilabel}`Use cookie for manual override` should be set along with {guilabel}`Set the language cookie always`.
45
76
46
-
In any case, building websites with user interfaces in multiple languages is a hard work due to the different expectations of the users and the difficulty of the configuration.
77
+
Building websites with user interfaces in multiple languages is complicated due to the different expectations of the users and the difficulty of the configuration.
47
78
48
-
### plone.app.multilingual is enabled
49
79
50
-
When plone.app.multilingual is enabled, Plone creates the so called `Language Root Folder`s (LRFs for short) for each of the languages, so the language negotiation only applies for the users visiting the root domain of the site.
For example, if 'en' and 'es' are enabled, Plone will create www.domain.com/en and www.domain.com/es, and Plone will assume that all the content below 'en' is in English and all content below 'es' is in Spanish, so it will rely on that assumption to present the user interface in those languages when the user is browsing those parts of the site.
82
+
## `plone.app.multilingual`is enabled
53
83
54
-
As we will see in the (translating-content-label)= section, Plone will set a special view for the Plone root object called `@@language-switcher` whose implementation lies on `plone.app.multilngual.browser.switcher.LanguageSwitcher`. This language switcher will only rely on the user preferred language to decide where to send the user when she visits the root of the site.
84
+
When `plone.app.multilingual` is enabled, Plone creates the `Language Root Folder`s (LRFs) for each of the languages.
85
+
Thus, the language negotiation only applies for the users visiting the root domain of the site.
55
86
56
-
If an integrator wants to modify this behavior to always send a user to a given language, or wants to negotiate the language selection in some other way (using the domain, a cookie, or some other techniques), she will have to override that `@@language-swicher` view, or will have to write her own view and set it as the `default view method` in the `Plone Site` object configuration in `www.domain.com/portal_types/Plone Site/manage_workspace`
87
+
For example, if `en` and `es` are enabled, Plone will create `www.domain.com/en` and `www.domain.com/es`.
88
+
Plone will assume that all the content below `en` is in English, and all content below `es` is in Spanish.
89
+
It will rely on that assumption to present the user interface in those languages when the user is browsing those parts of the site.
57
90
91
+
As we will see in the {ref}`translating-content-label` chapter, Plone will set a special view for the Plone root object called `@@language-switcher` whose implementation relies on `plone.app.multilngual.browser.switcher.LanguageSwitcher`.
92
+
This language switcher will only rely on the user preferred language to decide where to send the user when they visit the root of the site.
58
93
94
+
An integrator may want to modify this behavior to always send a user to a given language, or to negotiate the language selection in some other way, such as using the domain, a cookie, or some other techniques.
95
+
As such, there are two options.
96
+
97
+
- They may override the `@@language-switcher` view.
98
+
- They may write their own view, and configure the ZMI.
99
+
To configure the ZMI, visit `www.domain.com/portal_types/Plone%20Site/manage_propertiesForm` or navigate there as an Admin user, {guilabel}`username > Site Setup`, {guilabel}`Advanced > Management Interface`, {guilabel}`portal_types`, and finally {guilabel}`Plone Site`.
100
+
Set the value of `Default view method` to the name of the view.
0 commit comments