cakephp问题中的多种语言

发布于 2024-11-25 06:11:32 字数 254 浏览 0 评论 0原文

我正在尝试根据本教程建立一个多语言网站:

从点击切换语言链接的效果来看,事情看起来不错。但是,当您第一次访问该网站时,我希望它转到默认语言 example.com/eng/ 而不是 example.com/

基本上,出于搜索引擎优化的目的,我不希望我的网站有非语言内容,应该始终在网址中包含该语言。

我怎样才能做到这一点,并完成在会话/cookie 中保存语言的功能?

谢谢

I am trying to get a multilingual site up according to this tutorial:
http://nuts-and-bolts-of-cakephp.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/

Things look good in terms that clicking on a switch-language link works. However, when you first come to the site, i would like it to go to the default language example.com/eng/ instaed of just being example.com/.

Basically, for SEO purposes, I don't want my site to have non-lingual content, should always have the language in the url.

How could I do that and also go through the function that saves the language in session/cookie?

thanx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事↓在人 2024-12-02 06:11:32

看看这篇文章,您所需要的只是简单检查 URL 中的“语言”参数:

function beforeFilter() {
    // check and perform a redirect
    if (empty($this->params['language'])) {
        $this->redirect(array('language' => 'eng'));
    }
    // the following method sets any cookies
    $this->_setLanguage();
}

Looking at the article, all you should need is a simple check for the 'language' param in the URL:

function beforeFilter() {
    // check and perform a redirect
    if (empty($this->params['language'])) {
        $this->redirect(array('language' => 'eng'));
    }
    // the following method sets any cookies
    $this->_setLanguage();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文