Skip to content
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

Closed
wants to merge 82 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
265604b
[#4243] Tweaks to the new var-dumper component
weaverryan Nov 5, 2014
09a6fd7
[Form] Add entity manager instance support for em option
GeLoLabs Oct 18, 2014
1a29f24
typos in the var-dumper component
nicolas-grekas Nov 8, 2014
9caea6f
feature #4336 [Form] Add entity manager instance support for em optio…
weaverryan Nov 13, 2014
3329bd2
feature #4424 [#4243] Tweaks to the new var-dumper component (weaverr…
weaverryan Nov 13, 2014
0d5cb0d
Merge branch '2.7'
weaverryan Nov 13, 2014
0c92fab
Merge branch '2.7'
weaverryan Nov 13, 2014
51224e9
Merge branch '2.7'
wouterj Nov 19, 2014
d6ce29f
Merge branch '2.7'
weaverryan Nov 24, 2014
f24b645
Merge branch '2.7'
weaverryan Nov 24, 2014
d969e8b
Merge branch '2.7'
weaverryan Nov 25, 2014
0fb81cc
Merge branch '2.7'
weaverryan Nov 25, 2014
6b73990
Merge branch '2.7'
wouterj Dec 1, 2014
8099ac1
Merge branch '2.7'
weaverryan Dec 4, 2014
486baf8
Merge branch '2.7'
wouterj Dec 7, 2014
d921dcd
Merge branch '2.7'
wouterj Dec 7, 2014
f0ac8bb
Merge branch '2.7'
weaverryan Dec 7, 2014
3454883
Merge branch '2.7'
weaverryan Dec 7, 2014
d30dc9e
Merge remote-tracking branch 'origin/master'
weaverryan Dec 8, 2014
2d1c336
Merge branch '2.7'
weaverryan Dec 11, 2014
e539bd1
Merge branch '2.7'
weaverryan Dec 20, 2014
0906e0c
Merge branch '2.7'
weaverryan Dec 21, 2014
4056218
Merge branch '2.7'
weaverryan Dec 23, 2014
07aa543
Merge branch '2.7'
weaverryan Dec 26, 2014
2fcebc1
Merge branch '2.7'
wouterj Dec 28, 2014
8131844
Merge branch '2.7'
weaverryan Dec 29, 2014
cb6f846
Merge branch '2.7'
weaverryan Dec 31, 2014
9e5fc6c
Merge branch '2.7'
weaverryan Dec 31, 2014
56db7af
Merge branch '2.7'
weaverryan Dec 31, 2014
27296ad
Merge branch '2.7'
wouterj Dec 31, 2014
353995e
Merge branch '2.7'
weaverryan Jan 1, 2015
fcfea43
Merge branch '2.7'
wouterj Jan 2, 2015
6ef6a04
Merge branch '2.7'
weaverryan Jan 3, 2015
bcab77b
bump Symfony requirements to PHP 5.5
xabbuh Jan 4, 2015
d33b78b
don't describe removed usage of Yaml::parse()
xabbuh Jan 4, 2015
6f9832d
Merge branch '2.7'
wouterj Jan 4, 2015
42d2b15
Merge branch '2.7'
weaverryan Jan 4, 2015
7d2f0f3
Removed 2.5 versionadded as its deprecated
wouterj Jan 4, 2015
92b10b1
bug #4758 [Components][Yaml] don't describe removed usage of Yaml::pa…
wouterj Jan 8, 2015
032a6b4
Merge branch '2.7'
wouterj Jan 8, 2015
c859790
Fixed markup
wouterj Jan 9, 2015
9919bca
Revert "Fixed markup"
wouterj Jan 9, 2015
ca3b4c8
feature #4753 bump Symfony requirements to PHP 5.5 (xabbuh)
wouterj Jan 16, 2015
a17bdd7
Merge branch '2.7'
wouterj Jan 16, 2015
dc25c65
minor #4769 [2.7] Removed 2.5 versionadded as its deprecated (WouterJ)
weaverryan Jan 16, 2015
050f7ce
Documented true regex
wouterj Jan 18, 2015
7363c9b
Merge branch '2.6' into 2.7
weaverryan Jan 18, 2015
907ee0d
Merge branch '2.7'
weaverryan Jan 18, 2015
728205f
Replaced setDefaultOptions by the new configureOptions method
peterrehm Jan 6, 2015
74d2e30
feature #4786 Replaced setDefaultOptions by the new configureOptions …
weaverryan Jan 21, 2015
885c378
[#4786] Adding a few versionadded's for the changed method name
weaverryan Jan 21, 2015
e4d22f0
added documentation for the new absolute_url() and relative_path() Tw…
fabpot Jan 10, 2015
6e6bae8
Small grammar-ish fix
wouterj Jan 25, 2015
6c498d4
feature #4805 added documentation for the new absolute_url() and rela…
weaverryan Jan 25, 2015
8fe9069
added documentation for the new absolute_url() and relative_path() Tw…
fabpot Jan 10, 2015
a5addaa
[#4805] Adding versionadded
weaverryan Jan 25, 2015
61ea87b
Merge branch '2.6' into 2.7
weaverryan Jan 25, 2015
c33b371
Merge branch '2.7'
weaverryan Jan 25, 2015
7c07a44
Merge branch '2.6' into 2.7
weaverryan Jan 25, 2015
99e2996
Merge branch '2.7'
weaverryan Jan 25, 2015
a57db5b
feature #4879 Documented true regex (WouterJ)
weaverryan Jan 30, 2015
39f6876
Merge branch '2.6' into 2.7
weaverryan Jan 30, 2015
714f630
Merge branch '2.7'
weaverryan Jan 30, 2015
bc29584
Merge branch '2.6' into 2.7
wouterj Jan 30, 2015
87eb36c
Merge branch '2.7'
wouterj Jan 30, 2015
d71fe6d
Merge branch '2.6' into 2.7
wouterj Feb 1, 2015
c0f9f67
Merge branch '2.7'
wouterj Feb 1, 2015
78f4f69
Merge branch '2.6' into 2.7
wouterj Feb 1, 2015
ebe2706
Added January changelog
wouterj Feb 1, 2015
ad97700
Merge branch '2.7'
wouterj Feb 1, 2015
6fd286b
Added January changelog
wouterj Feb 1, 2015
7f8d6bd
Merge branch '2.6' into 2.7
wouterj Feb 1, 2015
8d56ad7
Merge branch '2.7'
wouterj Feb 1, 2015
ef39a01
Remove diff
wouterj Feb 1, 2015
70902f5
Merge branch '2.6' into 2.7
weaverryan Feb 1, 2015
81e8c13
Merge branch '2.7'
weaverryan Feb 1, 2015
b7f7421
Update translation.rst
solazs Feb 11, 2015
94914c5
Review note about setting the translator locale in a controller.
solazs Feb 15, 2015
d5566b1
Finaly touches on translation locale setting note
solazs Feb 20, 2015
fdae4bc
Merge branch 'master' of https://github.com/solazs/symfony-docs into …
solazs Mar 6, 2015
cbc91e3
Remove useless setLocale() call and add code block with locale setter
solazs Mar 6, 2015
30b4dfa
Revert "Merge branch 'master' of https://github.com/solazs/symfony-do…
solazs Mar 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing

(e.g. in a custom listener) or use the ``setLocale()`` method of the
``translator`` service.
Copy link
Member

Choose a reason for hiding this comment

The 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 $request->setLocale() above is misleading. It does serve to highlight that this method exists, which is good, but as we point out, setting the locale won't actually work.

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:

  • Remove the setLocale in the code block above
  • Add another code block showing an event listener that is calling setLocale, and just mention quickly that this would be an event listener on kernel.request, with a link to the event listener sections.

What do you all think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

  • Remove the setLocale in the code block above
  • Add another code block showing an event listener that is calling setLocale, and just mention quickly that this would be an event listener on kernel.request, with a link to the event listener sections.

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::

Expand Down