Quantcast

Translation of URI segments in ZF2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Translation of URI segments in ZF2

Jonathan Maron
Hello all

Continuing my testing of ZF2 beta4, I have come across the requirement
to translate the segments of a Zend\Navigation\Page\Uri.

I am trying to route the following URIs:

/en_US/products/cameras/  <-- translated segments
/de_DE/produkte/kameras/
/fr_FR/produits/cameras/

/zh_CN/products/cameras/  <-- default locale
/de_DE/produkte/kameras/
/ko_KR/produkte/kameras/

Using a Zend\Mvc\Router\Http\Segment with:

route => '/[:locale/][:controller/[:action/]]'

I can access the locale, and in en_US, ProductsController and
camerasAction() are called.

How do I go about routing /de_DE/produkte/kameras/ to the same
controller and action?

Currently, the documentation at http://j.mp/LyK8Kp describes the
"translation of labels and titles", but not of URI segments, hence my
question.

(note, the locale is required in the URI, as there is no segment
translation in some non-Western languages)

Thank you in advance.

Jonathan Maron

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Translation of URI segments in ZF2

Jonathan Maron
On Fri, Jun 29, 2012 at 9:51 AM, Jurian Sluiman <[hidden email]> wrote:

> 2012/6/29 Jonathan Maron <[hidden email]>
>>
>> How do I go about routing /de_DE/produkte/kameras/ to the same
>> controller and action?
>>
>> Currently, the documentation at http://j.mp/LyK8Kp describes the
>> "translation of labels and titles", but not of URI segments, hence my
>> question.
>
>
> The current Zend\Mvc\Route does not have support for translated segments
> yet. See for example the code
> here: https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/Router/Http/Segment.php#L230
>
> I think after Ben (DASPRiD) finished the Zend\I18n part, there will be some
> work done in i18n for routes, but for now you can't translate the segments.

Hello Jurian

Thanks for the heads up. If I am not mistaken, the updated Zend\I18n
part is due in beta5. I look forward to reviewing it.

Thank you again for your assistance.

With best regards

Jonathan Maron

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Loading...