[FLOW3-general] localization with FLOW

David Sporer david.sporer at gmail.com
Fri Dec 14 15:48:58 CET 2012


Hi Frederico,

don't know if this helps you but I'm doing similar things by using the
locale as session variable.
So in my initializeAction I'm checking if the session variable is set - if
not I'm assigning the browser locale.
If the user changes the language I'm writing the selected language to the
session variable.

Doing it this way you don't need to use arguments for your link view
helpers.

Regards
David


2012/12/14 Federico Bernardin <typo3list at bernardin.it>

> Hi list,
> I'm playing with FLOW and I'm implementing the localization for my test
> package but I have some problem.
>
> What I need is to create a route (example:
> www.mysite.com/it/mypackage/mycontroller/myaction) with a language
> parameter. THis part is easy and I already implemented it.
> The I would like to create link in the same format:
> www.mysite.com/it/mypackage/mycontroller/myaction.
>
> I created this route:
>
> -
>   name: 'language'
>   uriPattern: '{@locale}/{@package}/{@controller}(/{@action})'
>   defaults:
>     '@package':    'MyPackage'
>     '@controller': 'Standard'
>     '@action':     'index'
>     '@format':     'html'
>
> Then I create the initialize action into controller:
>
> public function initializeAction(){
>                 $arguments = $this->request->getArguments();
>                 if(isset($arguments['@locale'])){
>                         $localeDetector=
> $this->objectManager->get('TYPO3\FLOW3\I18n\Detector');
>                         $locale =
> $localeDetector->detectLocaleFromLocaleTag($arguments['@locale']);
>                         $i18nService =
> $this->objectManager->get('TYPO3\FLOW3\I18n\Service');
>                         if
> ($i18nService->getConfiguration()->getCurrentLocale() !== $locale) {
>
> $i18nService->getConfiguration()->setCurrentLocale($locale);
>                         }
>                 }
>         }
>
> Then I would like use fluid link.action to create an action to my
> controller. I tried to use arguments parameter: <f:link.action
>  action="myaction" arguments="{@locale:it}">Go to myaction</f:link.action>
> but it doesn't work because my argument has @ (I supposed). With locale
> without @ it works but I would like to use the route written before.
>
> Can you help me?
>
> Thanks
> Federico
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>


More information about the FLOW3-general mailing list