Skip to content

Commit ab7f942

Browse files
committed
docs: add "Setting the Locale" section
1 parent 4689e3f commit ab7f942

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

user_guide_src/source/outgoing/localization.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ method that will automatically perform :doc:`content negotiation </incoming/cont
5252
determine the correct locale to use. The second method allows you to specify a segment in your routes that
5353
will be used to set the locale.
5454

55-
Should you ever need to set the locale directly you may use ``IncomingRequest::setLocale(string $locale)``.
55+
Should you ever need to set the locale directly, see `Setting the Locale`_.
5656

5757
Content Negotiation
5858
-------------------
@@ -91,6 +91,18 @@ file:
9191

9292
.. note:: The ``useSupportedLocalesOnly()`` method can be used since v4.3.0.
9393

94+
Setting the Locale
95+
==================
96+
97+
If you want to set the locale directly, you may use
98+
``IncomingRequest::setLocale(string $locale)``.
99+
You must set supported locales in **app/Config/App.php**:
100+
101+
.. literalinclude:: localization/003.php
102+
103+
Any attempt to set a locale not included in this array will result in the default
104+
locale being set.
105+
94106
Retrieving the Current Locale
95107
=============================
96108

0 commit comments

Comments
 (0)