This is my setup (in bootstrap file):

$zcf = Zend_Controller_Front::getInstance();

$router = $zcf->getRouter();
$route = new Zend_Controller_Router_Route(
    ':language/:module/:controller/:action/*',
        array(
            'language'   => 'en',
            'module' => 'default',
            'controller' => 'index',
            'action'     => 'index'
        )
    );
$router->addRoute('default', $route);

And, in Actions / Views you can create URLs using the view helper $this->Url
and this will use the configured route to assemble the correct url.

On Jan 30, 2008 2:12 AM, p5ych0 <[EMAIL PROTECTED]> wrote:

>
>
> debussy007 wrote:
> >
> > Hi,
> >
> > I am internationalizating my web app and I need to know for every
> request
> > which language is chosen.
> >
> > So I want to add in the start of the url something like:
> > http://example.com/fr/myController/myAction
> > http://example.com/en/myController/myAction
> >
> > But this will make zend think "fr" and "en" is a module.
> >
> > How can I achieve this ?
> >
> > Thank you for any advice !!
> >
>
> i did something like following:
> 1) create and register a plugin
> 2) set a global or (Zend::Registry) variable which contains the list of
> languages
> 3) in plugin
> public function routeStartup($request)
> {
>    global $language, $site_lang;
>    $path = $this->getPathInfo();
>    if ($path[0] == '/') {
>        $path = substr($path, 1);
>    }
>    preg_match("/^([a-z]+)\/.*|$/i", $path, $vars);
>    if (in_array($vars[1], $languages)) {
>        $site_lang = $var[1];
>        $path = '/' . substr($path, strlen($var[1]));
>        $request->setPathInfo($path);
>    }
> }
>
> in that way we have the default router working as usual, and a language
> variable set
>
> have fun
> --
> View this message in context:
> http://www.nabble.com/changing-the-url-tp14778862s16154p15173562.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>


-- 
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://web.xaviervidal.net
610.68.41.78

Reply via email to