CakePHP 2.x i18n route

前端 未结 2 1853
余生分开走
余生分开走 2021-01-26 00:13

There is some solution for using CakePHP route with params only when are not empty?

Now I code below, but I would like some better:

if(Configure::read(\'         


        
2条回答
  •  孤街浪徒
    2021-01-26 01:17

    Ok, these things work better, but I still other problem.

    I set default language by Configure::write('Config.language'); to en in bootstrap.php

    Next i wrote shema for url like this:

    Router::connect('/:language/'. __('register', true), array('controller' => 'users', 'action' => 'register'), array('persist' => array('lang')));
    Router::connect('/'. __('register', true), array('controller' => 'users', 'action' => 'register')); 
    

    And when users change language by beforeFilter in AppController (set new Config.language) will content from static .po and db worsk perfeclty, but links not translated. Parametr :language works but magic function __() in Router:connect() not works.

    Because first loaded is bootstrap.php, next is router.php and last is AppController.php

    My question is, how to force router.php to translate links (__())?

    Sorry, but still learn english...

提交回复
热议问题