I' working on a bilingual site that will have several static pages,
plus some dynamic. The static pages will all be translated and the
dynamic views will use .po files for interface stuff. Dynamic
*content* will not require translating. I found an article on
teknoid's site(1) that seems to be what I need to get this working but
I'm having some trouble figuring out my routes for static files.

With a basic nested directory structure for static files, I can
normally do this:

Router::connect(
        '/some_dir/something',
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display', '/
some_dir/something')
);

This works fine. But, adding language into the mix has made things
very confusing. As an example:

routes:
Router::connect(
        '/:language/:controller/:action/*',
        array(),
        array('language' => 'en|fr')
);
Router::connect(
        '/en',
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display',
'language' => 'en', '/en/home')
);
Router::connect(
        '/fr',
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display',
'language' => 'fr', '/fr/home')
);

Router::connect(
        '/en/about',
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display',
'language' => 'en', '/en/about')
);
Router::connect(
        '/en/links',
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display',
'language' => 'en', '/en/links')
);

links:
$lang = Configure::read('Config.language');
...
echo $html->link(
        __('Home', true),
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display',
'language' => $lang, "${lang}/home")
);

echo $html->link(
        __('About', true),
        array('admin' => 0, 'controller' => 'pages', 'action' => 'display',
'language' => $lang, "${lang}/about")
);

AppHelper:
public function url($url = null, $full = false)
{
        if (!isset($url['language']) && isset($this->params['language']))
        {
                $url['language'] = $this->params['language'];
        }
        else
        {
                $url['language'] = Configure::read('Config.language');
        }
        return parent::url($url, $full);
}

URLs created:

/en/pages/display/en/home
/en/pages/display/en/about

Obviously, this isn't working. Aside from the unwanted 'pages/display'
part, there's an extra 'en' in there. Can anyone tell me where I'm
going wrong?

(1) 
http://teknoid.wordpress.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to