Skip to content

Commit bddbb95

Browse files
committed
fix: Move code to file
1 parent 76cca3f commit bddbb95

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

user_guide_src/source/incoming/content_negotiation.rst

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,15 @@ that the strict comparison will be made in the first place.
121121
if you have your own translation files, you **must also change** the folder names for CodeIgniter's translation files to match
122122
what you put in the ``$supportedLocales`` array.
123123

124-
Now let's consider the below example. The browser's preferred language will be set as this::
124+
Now let's consider the below example. The browser's preferred language will be set as this::
125125

126126
GET /foo HTTP/1.1
127127
Accept-Language: fr; q=1.0, en-GB; q=0.5
128128

129-
In this example, the browser would prefer French, with a second choice of English (United Kingdom). Your website on another hand will
129+
In this example, the browser would prefer French, with a second choice of English (United Kingdom). Your website on another hand
130130
supports German and English (United States):
131131

132-
.. code-block:: php
133-
134-
$supported = [
135-
'de',
136-
'en-US',
137-
];
138-
139-
$lang = $request->negotiate('language', $supported);
140-
// or
141-
$lang = $negotiate->language($supported);
132+
.. literalinclude:: content_negotiation/008.php
142133

143134
In this example, 'en-US' would be returned as the current language. If no match is found, it will return the first element
144135
in the ``$supported`` array. Here is how exactly the locale selection process works.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$supported = [
4+
'de',
5+
'en-US',
6+
];
7+
8+
$lang = $request->negotiate('language', $supported);
9+
// or
10+
$lang = $negotiate->language($supported);

0 commit comments

Comments
 (0)