[Flow] Question about Languages and URL/Routing
Christian Loock
chl at vkf-renzel.de
Mon Jun 2 16:38:09 CEST 2014
Hi,
Yeah, well that makes it quite a bit more complex. It would also depend
on how you handle your i18n.
You could create an abstract controller, that each of your controllers
derive from. In this, you could write an initializeAction, that handles
request variables and thus changes the language in the session. You
would need to set a request parameter inside your route that determines
the language. However, I do not know how you could fetch the request
information inside your initializeAction. (TYPO3\Flow\Http\ Request::
createFromEnvironment might do it)
Another way would be to write an aspect that is executed before each
action of your controllers. This way you wouldn't have to change all
your controllers. Just look into the AOP documentation of Flow.
On 02.06.2014 15:16, David Sporer wrote:
> Hmm yeah but that would mean the user must do something before right?
> What I want is that if the user goes to my page he's redirected to the
> correct language first (that's the easy task).
> Means en as locale will result in the URL with /en/
> And de as locale will result in https://portal.passcreator.de/ without the
> en.
> But now all links that are created by the link view helper etc. should also
> contain /en/ in the URL if the language is English.
> Does this also work by just creating a route for /en/?
> I think I must accept the language code as a parameter for every action
> then or something? Maybe I can pass this as parameter to the
> initializeView-Method but I'm not sure if this will create all links with
> the en if the language is english.
>
> Thank you!
>
>
> 2014-06-02 14:58 GMT+02:00 Christian Loock <chl at vkf-renzel.de>:
>
>> Couldnt you just write a controller and a route that does this?
>>
>> For example, you have a route for /en/ that points to a controller that
>> then changes the session variable you were mentioning before.
>>
>>
>>
>> On 02.06.2014 14:46, David Sporer wrote:
>>
>>> Hey Guys,
>>>
>>> until now my project uses always the same urls for both languages and I'm
>>> determining the language by the users' locale.
>>> If the user changes the language I'm saving this in a session parameter so
>>> it doesn't switch back on the next page.
>>>
>>> But as I said, the URL is always the same.
>>> How can I configure german as default language and use the same URLs for
>>> it
>>> I'm using right now e.g. https://portal.passcreator.de/
>>> and for the english version https://portal.passcreator.de/en/?
>>>
>>> Is this just a Routing issue or do I have to do something more?
>>>
>>> Regards
>>> David
>>> _______________________________________________
>>> Flow mailing list
>>> Flow at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>>
>> --
>> Christian Loock
>> Web Developer
>> Renzel Agentur
>> www.renzel-agentur.de
>>
>>
>> _______________________________________________
>> Flow mailing list
>> Flow at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
--
Christian Loock
Web Developer
Renzel Agentur
www.renzel-agentur.de
More information about the Flow
mailing list