CMS 中多语言内容的数据建模?

发布于 2024-12-15 06:14:09 字数 379 浏览 2 评论 0原文

是否有一个普遍接受的解决方案用于在数据库中存储多语言内容?我曾经工作过的公司让我构建一个专有的 CMS,他们希望能够动态支持语言。那时我还很陌生,所以我有一个表“语言”来保存语言,还有一个表“内容”来保存逻辑删除数据(published_datetime、modified_datetime、expiry_datetime 等)。

为了保存实际内容,我有一个名为“ContentBody”的表,其中有一列:语言_id、内容_id、标题和内容。

这个解决方案有效,但我并没有真正费心去进一步研究它。我目前发现自己有很多空闲时间,并决定再次涉足 CMS 开发,这是我一直觉得自己做得不对的方面之一。我查看了 WordPress ERM 图,它似乎没有用于多语言内容的表格。

任何建议或评论都会很棒:)

Is there a generally accepted solution for storing multilingual content in a database? The company I used to work for had me build a proprietary CMS and they wanted the possibility to support languages dynamically. I was pretty green then so I had a table "Languages" to hold languages and a table "Content" that held the tombstone data (published_datetime, modified_datetime, expiry_datetime, etc.).

To hold the actual content I had a table called "ContentBody" which had a columns: language_id, content_id, title, and content.

This solution worked but I didn't really bother looking more into it. I currently find myself with a lot of free time on my hands and decided I'd dabble again in CMS development and this is one of those aspects of it that I always felt I hadn't done right. I looked at the WordPress ERM diagram and it doesn't seem to have a table for multilingual content.

Any advice or comments would be awesome :)

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

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

发布评论

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

评论(1

层林尽染 2024-12-22 06:14:09

假设您的要求与您所说的完全一样,我将采用具有复合键 content_id + language_id 的内容表。就这么简单,除非您有其他 CMS 要求(例如版本控制、工作流程、审批流程等),这会使事情变得复杂。

Having a content table with compound key content_id + language_id is the approach I would follow, assuming your requirements are exactly as you stated. It's that simple unless you have other CMS requirements (e.g. versioning, workflow, approval process, etc) that would complicate it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文