-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update translation.rst #4989
Update translation.rst #4989
Changes from 2 commits
265604b
09a6fd7
1a29f24
9caea6f
3329bd2
0d5cb0d
0c92fab
51224e9
d6ce29f
f24b645
d969e8b
0fb81cc
6b73990
8099ac1
486baf8
d921dcd
f0ac8bb
3454883
d30dc9e
2d1c336
e539bd1
0906e0c
4056218
07aa543
2fcebc1
8131844
cb6f846
9e5fc6c
56db7af
27296ad
353995e
fcfea43
6ef6a04
bcab77b
d33b78b
6f9832d
42d2b15
7d2f0f3
92b10b1
032a6b4
c859790
9919bca
ca3b4c8
a17bdd7
dc25c65
050f7ce
7363c9b
907ee0d
728205f
74d2e30
885c378
e4d22f0
6e6bae8
6c498d4
8fe9069
a5addaa
61ea87b
c33b371
7c07a44
99e2996
a57db5b
39f6876
714f630
bc29584
87eb36c
d71fe6d
c0f9f67
78f4f69
ebe2706
ad97700
6fd286b
7f8d6bd
8d56ad7
ef39a01
70902f5
81e8c13
b7f7421
94914c5
d5566b1
fdae4bc
cbc91e3
30b4dfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,14 @@ via the ``request`` object:: | |
|
||
$request->setLocale('en_US'); | ||
} | ||
|
||
.. note:: | ||
|
||
Setting the locale using the ``$request->setLocale()`` method won't affect | ||
rendering in the same action. The translator locale is set during the | ||
kernel.request event. Either set the locale before the listener is called | ||
(e.g. in a custom listener) or use the ``setLocale()`` method of the | ||
``translator`` service. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a really great point and thing to add. But I think showing the Are there downsides to setting the locale directly on the translator from the controller? Or do we think this is kind of hackish? If it is hackish (it seems so to me, but I also can't think of a real downside), then I think we should:
What do you all think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does feel hackish, but I can't really see why it shouldn't be done this way. It works perfectly and I could not find any other way to change the local of the translator in the controller. I believe it feels hackish, because the translator service is normally not accessed, so this means another depency. This shouldn't cause any problems though.
This is a great idea! I'll sketch a new version as soon as I can and push it, see if you like it. |
||
|
||
.. tip:: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, one more thing before I'll label it as "finished": Could you please put
kernel.request
in a literal (double backticks) as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing