[Neos] Language detection via url

Christopher Hlubek hlubek at networkteam.com
Fri May 9 15:51:18 CEST 2014


Hi Lars,

in Neos 1.1 we introduced the new Content Dimensions for Nodes that support multiple variants of the same Node in different dimensions. One dimension could be a set of "locales". There is experimental support for a LocalizedFrontendNodeRoutePartHandler that can be configured in Objects.yaml as the implementation of FrontendNodeRoutePartHandlerInterface. This route part handler could be extended for the language detection.

Besides the router you have to:

- Enable the content dimension "locales" (see Settings.yaml of TYPO3.TYPO3CR)
- Run the node migration 20140326143834 to set the dimension values for existing nodes
- Configure dimension presets (see contentDimensions in Settings.yaml of TYPO3.Neos)

This will be documented and become easier in the future, but right now it is experimental to use some of these features.

About the cache issue:

If the language is part of the node it should be cached correctly, since each language has a different node context path that is a part of the cache entry identifier. You could also add your request parameter to the following places to include it in the cache entry identifiers (which means you'll end up with different cache entries depending on the language):

root. at cache.entryIdentifier.language = ${request.arguments.language}
page. at cache.entryIdentifier.language = ${request.arguments.language}

Maybe you have to add "prototype(TYPO3.Neos:ContentCollection). at cache.entryIdentifier.language = ${request.arguments.language}" too if your content is show in the wrong language.

Greetings,

Christopher

Am 09.05.2014 um 10:38 schrieb Lars Peipmann <lars at peipmann.de>:

> I have implemented this Flow-BlogPost of Steffen Ritter
> http://blog.steffen-ritter.net/2014/04/language-detection-url-parameter-typo3-flow/
> in my Neos 1.1-beta2 web site.
> 
> I've got two problems:
> 
> 1) How to configure the "language" URL parameter in the Routes-Configuration (Routes.yaml) of Neos with "uriPattern: '<TYPO3NeosSubroutes>'"?
> 
> 2) In my Neos 1.1-beta2 instance the cache ignores the language parameter.
> clear cache > call a page: every output & link is correct
> switch language in the URL on a cached page: page gets loaded from cache (without adjusting the output & links)
> 
> This is my language switch:
> page.body.settings {
>   language = ${request.arguments.language}
> }
> 
> 		<f:if condition="{settings.language} == 'en'">
> 			<f:then>
> 				<neos:link.node arguments="{language: 'de'}">Deutsch</neos:link.node>
> 			</f:then>
> 			<f:else>
> 				<neos:link.node arguments="{language: 'en'}">English</neos:link.node>
> 			</f:else>
> 		</f:if>
> 
> Is this solution "ok"? Or is there a much better way to do that?
> 
> Best, Lars
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos



More information about the Neos mailing list