2013-11-08 16:30
浏览 36


We're busy with a CakePHP project which needs to support multi languages. But there is one problem.... There are pages which are NOT supported for other languages. So there are Spanish pages which need to be hidden for the Italian version of the website. What is the better solution for this in CakePHP?

We can switch databases as soon as you switch languages, but the problem is that we will miss important data as users and such if we'll do that. And it may be overload to search a database with Spanish, Italian, German, English, Netherlands and Swedish posts, only for the Spanish posts. Or maybe it's not a problem if we index the language column... but I don't know.

So does anyone knows the better solution?

图片转代码服务由CSDN问答提供 功能建议

我们正忙于一个需要支持多种语言的CakePHP项目。 但是有一个问题......有些页面支持其他语言 NOT 。 因此,对于意大利语版本的网站,需要隐藏西班牙语页面。 CakePHP中有什么更好的解决方案?

我们可以在切换语言后立即切换数据库,但问题是我们会错过重要数据作为用户等我们会这样做 去做。 搜索西班牙语,意大利语,德语,英语,荷兰语和瑞典语的数据库可能会超载,仅限于西班牙语帖子。 或者,如果我们索引语言列,这可能不是问题...但我不知道。


  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanlei0282 2013-11-16 22:11

    Definitely NOT multiple databases IMO. Instead, try to just keep your record separate from it's contents.


    articles table contains non-language-specific data like article id, created date, modified date...etc

    article_contents contains language-specific data like title, subtitle, content, authors...etc as well as an article_id field and a language field.

    Then, if you're on the Italian site, you can pull with an INNER JOIN to the contents where it matches the language you want.

    Or there are many ways depending on your setup on how you should pull data, but hopefully the idea for separation of generic data vs language-specific data helps.

    解决 无用
    打赏 举报
  • doulu6314 2013-11-16 21:20

    instead of

     echo 'Localization';


     echo __('Localization');

    解决 无用
    打赏 举报

相关推荐 更多相似问题