same problem for 1 day :-D
routes.php
Router::connect(
'/:lang/:controller/:action/*',
array(),
array('lang' => '[a-z]{2}')
);
Router::connect(
'/:lang/:controller',
array('action' => 'index'),
array('lang' => '[a-z]{2}')
);
app/config/core.php
// Set default language
Configure::write('Config.language', 'de');
cake/libs/controller
var $components = array('Session', 'Cookie');
function beforeFilter() {
$this->_setLanguage();
}
function _setLanguage() {
if ($this->Cookie->read('lang') && !$this->Session-
>check('Config.language')) {
$this->Session->write('Config.language', $this->Cookie-
>read('lang'));
}
else if (isset($this->params['lang']) && ($this->params['lang']
!= $this->Session->read('Config.language'))) {
$this->Session->write('Config.language', $this-
>params['lang']);
$this->Cookie->write('lang', $this->params['lang'], false,
'20 days');
}
}
Link musst looks like
domain/en/controller
domain/jp/controller
Have fun :)
On 27 Jul., 21:19, leafchild <leafchild.b...@gmail.com> wrote:
> I want to have 2 languages site (en/jp) and JP is default language.
> I look at multi-language pages but still confusing,,,
>
> ex)http://book.cakephp.org/view/1228/Internationalization-Localizationhttp://book.cakephp.org/view/1328/Translate
>
> and url will be:
> JP : mydomain.com/whatever
> EN: mydomain.com/en/whatever
>
> also EN pages has less page than JP pages which mean EN doesn't have
> all pages for JP pages.
> What should I do when there is no EN page?
>
> I don't thinkhttp://book.cakephp.org/view/1228/Internationalization-Localization
> works for my site.
> There are a lot of long sentence that need to be covered, plus this
> one not changing URL but changing contents.
>
> Should I just use Configure::write('Routing.prefixes', array('en'));??
> because structure of 2 sites are not exactly same but share some
> section.
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment