Routing - How to use internationalization in cakephp with custom url and extensions


I am using cakephp 2.0 for an application … everything is fine but i am getting some problem with custom ulr or SEO friendly url.

Here are Route rules that i am using

Router::parseExtensions(‘html’, ‘rss’, ‘xml’,‘json’);
Router::connect(’/:language/:controller/:action/*’,array(),array(‘language’ => ‘eng|chi’));
Router::connect(’/’, array(‘controller’ => ‘homes’, ‘action’ => ‘index’),array(‘language’ => ‘eng|chi’));

Router::connect('/backend/*', array('controller' => 'users', 'action' => 'login', 'lab' => true));
Router::connect('/about-us/*', array('controller' => 'homes', 'action' => 'about_us'));
Router::connect('/contact/*', array('controller' => 'homes', 'action' => 'contact'));
Router::connect('/:slug', array('controller' => 'homes', 'action' => 'page'), array('pass' => array('slug'), 'slug'=>'[a-zA-Z0-9-]*'));

Here for “about-us”, ‘contact-us’ and 3rd and main one is “:slug” ( dynamic )

problem 1) When i try to change language, url is showing lang/controller/action ( localhost/cake_app/eng/homes/about_us ) instead of localhost/cake_app/eng/about-us.html or localhost/cake_app/chi/about-us.html

problem 2) for other dynamic url eg localhost/cake_app/page-1.html, localhost/cake_app/page-2.html, localhost/cake_app/page-3.html so on … how to use localhost/cake_app/lang/slug with .html ( localhost/cake_app/eng/page-1.html or localhost/cake_app/chi/page-1.html)

for this i am using Router::connect(’/:slug’, array(‘controller’ => ‘homes’, ‘action’ => ‘page’), array(‘pass’ => array(‘slug’), ‘slug’=>’[a-zA-Z0-9-]*’)) rule.