开发者

How do I get translated URIs and controllers in CakePHP for a multi-lingual website

Hello all and thanks in advance for taking a look and I appreciate any help possible. I'm an SEO guy and have inherited a CakePHP site that will serve content in three languages. I'd like to get a canonical (seo friendly) way to get a good multilingual URL architecture without making my developer too upset.

The end solution of what we want:

Nice URLs with three distinct URLs (translated) for each language. For example:

www.domain.com/L1/language-1-parent/language-1-child/ www.domain.com/L2/language-2-parent/language-2-child/ www.domain.com/L3/language-3-parent/language-3-child/

Here, we have one content piece. This content will be the same in all three languages, but it will be translated. Accordingly, we want the corresponding subdirectories and URIs to be translated as well, where:

L{1-3} are subdirectories indicating the language

language-{1-3} are 'controllers' for the content. Currently we only have one controller, regardle开发者_开发技巧ss whether the language subdirectories are in a different language).

langauge-{1-3}-child are dependent content items or subdirectries that must also be translated based upon the language subdirectories


The Assumed Problem:

My developer is telling me that because Cake has controllers that serve the content up and as such having translations is a bit messy. In the example above: I assume that 'language-1,' language-2,' and 'language-3' are the controllers.

Also, I'm assuming that because we're trying to serve up three content versions from one controller (with different URLs), we're running into a problem.

Currently we have URLs as such:

www.domain.com/L1/language-1-parent/language-1-child/ www.domain.com/L2/language-1-parent/language-1-child/ www.domain.com/L3/language-1-parent/language-1-child/

The problem here is that regardless whether a user selects a different language, we have the URLs that do not correspond and are not translated. Also, we do have some content items that do not have other language translations. As such, I want to put in a rel=canonical meta tag on the pages without translations and/or noindex these pages whilst we{re working on translations.

Again, your help is MASSIVELY appreciated and I look forward to your responses. I'm happy to clarify anything.


With standard cakephp configuration you can easily achieve these kind of URLs using cakephp internationlization

/eng/users/account
/fre/users/account

If you need these king of URLs

/eng/users/account
/fre/utilisateurs/compte

Then you should play with your AppController.php

// pseudo code, you need to rewrite this section as you need.
var lang getUrlParams['language'];
var controller getUrlParams['controller'];
var action getUrlParams['action'];

if (controller[lang] != controller || action[lang] != action) :
    redirect to `/lang/controller[lang]/action[lang]`;
endif;

In view's all links should be called like

$this->Html->link(__('My Link'), array('controller' => __('users'), 'controller' => __('account')))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜