92
92
Setting the Current Locale
93
93
==========================
94
94
95
- If you want to set the locale directly, you may use
96
- ``IncomingRequest::setLocale(string $locale) ``.
95
+ IncomingRequest Locale
96
+ ----------------------
97
+
98
+ If you want to set the locale directly, you may use the ``setLocale() `` method in
99
+ the :doc: `../incoming/incomingrequest `:
100
+
101
+ .. literalinclude :: localization/020.php
102
+ :lines: 2-
97
103
98
104
Before setting the locale, you must set valid locales. Because any attempt to
99
105
set a locale that are not valid will result in
@@ -108,6 +114,18 @@ in **app/Config/App.php**:
108
114
set (and reset) valid locales. Use it if you want to change the valid locales
109
115
dynamically.
110
116
117
+ Language Locale
118
+ ---------------
119
+
120
+ The ``Language `` class used in the :php:func: `lang() ` function also has the current
121
+ locale. This is set to the ``IncommingRequest `` locale during instantiating.
122
+
123
+ If you want to change the locale after instantiating the language class, use the
124
+ ``Language::setLocale() `` method.
125
+
126
+ .. literalinclude :: localization/021.php
127
+ :lines: 2-
128
+
111
129
Retrieving the Current Locale
112
130
=============================
113
131
@@ -218,10 +236,12 @@ Specifying Locale
218
236
-----------------
219
237
220
238
To specify a different locale to be used when replacing parameters, you can pass the locale in as the
221
- third parameter to the `` lang() ` ` function.
239
+ third parameter to the :php:func: ` lang() ` function.
222
240
223
241
.. literalinclude :: localization/016.php
224
242
243
+ If you want to change the current locale, see `Language Locale `_.
244
+
225
245
Nested Arrays
226
246
-------------
227
247
0 commit comments