CMS 中多语言内容的数据建模?
是否有一个普遍接受的解决方案用于在数据库中存储多语言内容?我曾经工作过的公司让我构建一个专有的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的要求与您所说的完全一样,我将采用具有复合键 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.