如何在SQL表中存储不同的语言数据? [英] How to store different language data in a SQL table?
本文介绍了如何在SQL表中存储不同的语言数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在国家/地区表中有一个国家/地区表我用英语存储了所有国家/地区。我的用户不知道如何管理sql server中的不同语言以及如何设计table.some用户需要2种语言一些用户需要更多如何处理。
我尝试过:
i创建了一个国家/地区表。
CountryID,CountryName
解决方案
如果我理解你的问题正确,您需要几张表来进行翻译。例如,下面的结构
语言表
- LanguageId, int , primary key
- 名称 varchar ( 10 ) - 例如'en-US'等文化
TextObject -table
- TextObjectId, int , primary key
- OriginalText varchar ( 1000 ) - 要翻译的文字
翻译-table
- TranslationId, int , primary key
- TextObjectId, int , - 要翻译的文本
- LanguageId,< span class =code-keyword> int - 要翻译的语言
- TranslatedText varchar ( 1000 ) - 翻译文本
数据示例
LanguageId名称
---------- ----
1 zh-US
2 fi-FI
3 sv-SE
4 fr-FR
TextObjectId OriginalText
------------ ------------
1数据库
2主席
TranslationId TextObjectId LanguageId TranslatedText
------------- --------- --- ---------- --------------
1 1 1数据库
2 1 2 Tietokanta
3 1 3 Databas
4 1 4 Basededonnées
5 2 1 Chair
6 2 2 Tuoli
7 2 3 Stol
8 2 4 La躺椅
i have a country table in the country table i have store all the country in english language .some of my user does not know english how to manage different language in sql server and how to design table.some of user need 2 language and some of user need more how to handle .
What I have tried:
i have create a country table.
CountryID,CountryName
解决方案
If I understand your question correctly, you need a few tables to do the translations. Considr for example a following structure
Language-table - LanguageId, int, primary key - Name varchar(10) -- for example Culture like 'en-US' etc TextObject -table - TextObjectId, int, primary key - OriginalText varchar(1000) -- text to translate Translation -table - TranslationId, int, primary key - TextObjectId, int, -- text to translate - LanguageId, int -- language to translate to - TranslatedText varchar(1000) -- translated text
Examples of data
LanguageId Name ---------- ---- 1 en-US 2 fi-FI 3 sv-SE 4 fr-FR TextObjectId OriginalText ------------ ------------ 1 Database 2 Chair TranslationId TextObjectId LanguageId TranslatedText ------------- ------------ ---------- -------------- 1 1 1 Database 2 1 2 Tietokanta 3 1 3 Databas 4 1 4 Base de données 5 2 1 Chair 6 2 2 Tuoli 7 2 3 Stol 8 2 4 La chaise
这篇关于如何在SQL表中存储不同的语言数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文