Twig¶
I have searched for a moment to find the solution to this problem so here the solution
If you want to do something like that in Twig :
{% set uriLocalized = currentUri|replace({ (currentLocale):lang }) %}
With
{% set currentUri = app.request.uri %} #Warning, this variable is from a render call on my main layout
{% set currentLocale = app.request.locale %}
{% set lang = "en" %}
You NEED to wrap the key with parentheses