如何在DB中引入字典国际化

发布于 2024-12-02 03:48:24 字数 522 浏览 0 评论 0原文

我有数据库和很多字典。到目前为止,它是用英语编写的,但客户希望在数据库级别引入国际化(以支持西班牙语和英国英语)。因此,登录我们系统的用户应该会看到所有文本,具体取决于他的国际化设置。

大多数字典表都是这样的形式:

CREATE TABLE UserPermissionTypes (
Id [INT],  
Title NVARCHAR(100),  
Description NVARCHAR (500) )

此时我正在考虑为每个字典创建重复的表,其形式类似于此:

CREATE TABLE UserPermissionTypesTranslations (
UserPermissionTypesId [INT],
LanguageCodeId [INT]
Title NVARCHAR(100),  
Description NVARCHAR (500), )

我知道这不是完美的解决方案,所以我想知道实现的最佳方法是什么表格国际化? 是否有某种标准方法可以实现国际化?

I have DB with many dictionaries. Till this moment it was written in english, but customer want to introduce internationalization on DB level (to support spanish and UK english). So users that will login to our system should see all text depending on his internationalization settings.

Most of dictionay tables are in form:

CREATE TABLE UserPermissionTypes (
Id [INT],  
Title NVARCHAR(100),  
Description NVARCHAR (500) )

At this moment I'm thinking about creating duplicated tables for each dictionary in form similiar to this one:

CREATE TABLE UserPermissionTypesTranslations (
UserPermissionTypesId [INT],
LanguageCodeId [INT]
Title NVARCHAR(100),  
Description NVARCHAR (500), )

I know that it is not perfect solution, so I want to know what is the best method to implement internationalization in tables?
Is there some standard way to do that inernationalization?

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

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

发布评论

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

评论(1

饭团 2024-12-09 03:48:24

如何制作额外的翻译表并使用它的 ID 而不是文本(在评论后修改):

    CREATE TABLE UserPermissions ( 
    Id [INT],   
    TitleTR [INT],   
    DescriptionTR [INT] ) 

    CREATE TABLE Translations(
    Id [INT],
    LanguageID [INT],
    Text NVARCHAR(500)
    )

select tr.Text as title, tr2.Text as description from UserPermissions
join Translations tr on tr.id=UserPermissions.titleTR and languageid=:LANG
join Translations tr2 on tr2.id=UserPermissions.descriptionTR and languageid=:LANG

How about making extra table for translations and use it's ID instead of texts (modified after comments) :

    CREATE TABLE UserPermissions ( 
    Id [INT],   
    TitleTR [INT],   
    DescriptionTR [INT] ) 

    CREATE TABLE Translations(
    Id [INT],
    LanguageID [INT],
    Text NVARCHAR(500)
    )

select tr.Text as title, tr2.Text as description from UserPermissions
join Translations tr on tr.id=UserPermissions.titleTR and languageid=:LANG
join Translations tr2 on tr2.id=UserPermissions.descriptionTR and languageid=:LANG
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文