如何在ASP.NET C#中创建多个语言的网站? [英] How to create website in multiple langauages in ASP.NET C#?

查看:64
本文介绍了如何在ASP.NET C#中创建多个语言的网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我已经创建了一个测验网站,但它只在Eng中。



现在,客户端要求是创建/更改以支持多种语言。



AddQuestion页面有一些下拉菜单,一个用于问题的文本框和用于答案的文本框。



我的问题是:

当问题在Eng中输入并作为Eng存储在DB中时,

它将如何显示/用其他语言显示。



我尝试过:



我添加了文化和资源文件来支持像阿拉伯语一样的语言。但这只会改变标签而不是文本框/下拉值。



任何人都可以建议我,如何解决这个问题。





谢谢

解决方案

这个想法很简单。数据库中的每个问题和答案都应该有一个键映射到资源文件中另一种语言的相应语句。


引用:

我已经创建了一个测验网站,但它只在Eng中工作。

现在,客户要求是创建/更改以支持多种语言。

猜猜你已完成ENG网站的页面模板,您必须为每种语言创建模板并设置一个标签,提醒您正在使用哪种语言。

引用:

当问题在Eng中输入并作为Eng存储在DB中时,

它将如何以其他语言显示/显示。

简答:它没有。

实际上,互联网上没有通用的自动翻译可以准确地翻译超出最基本句子的内容。

自己看 Google翻译 [ ^ ]

一句话得到一点复杂,这是错误的。


首先,目前没有自动将文本转换为任何特定语言。



因此,任何要输入的数据都要在保存输入数据的每个表中进行更改。



我的意思是假设你在表格中保存问题文本'tbl_questions'



 tbl_questions {question_id(PK)int,question_text nvarchar(max)} 





但现在你必须改变类型的question_text到ntext以支持多语言文本,还为语言添加了一个额外的字段,还有一个主键约束复合的question_id和languaage_id





 tbl_questions {question_id(PK) int ,language_id(PK) int ,question_text  ntext } 







现在,您必须以所选语言保存文本。这意味着如果您支持四种语言,则相同的问题文本必须相对于这些语言保存四次。



所以你需要在DB端进行更改。在前端意味着不需要改变。要呈现正确的文本,您必须根据当前选定的语言获取数据。



这就是我使用资源文件和db with ntext字段实现多语言网站的方式。


Hi Guys,

I have already created one Quiz Website but its only in Eng.

Now, Client requirement is to create/change to support mutiple languages.

AddQuestion page have some dropdowns, one textbox for Question and textboxes for Answers.

My question is:
When the question is entered in Eng and stored in DB as Eng,
how it will show/display in other languages.

What I have tried:

I have added Culture and resource files to support lang like Arabic. But this will change only the lables but not the textboxes/dropdowns values.

Can anyone please suggest me, how to solve this.


Thanks

解决方案

There is no magic yet the idea is simple. Each question and answer in the database should have a key that map to the corresponding one in another language in your resource file.


Quote:

I have already created one Quiz Website but its only in Eng.
Now, Client requirement is to create/change to support multiple languages.

Guessing that you have done pages templates for the ENG site, you will have to create templates for each language and set a tag that remind you which language is in use.

Quote:

When the question is entered in Eng and stored in DB as Eng,
how it will show/display in other languages.

Short answer: it don't.
Practically, no general purpose automatic translator on internet can accurately translate things beyond the most basic sentences.
See for yourself with Google Translate[^]
As soon as the sentence get a little complicated, it get s wrong.


First of all currently no automatic conversion for text to any specific language.

So, any data which is going to be input you've to make change in each table where those inputted data is being saved.

What I mean suppose you were saving Question text in table namely 'tbl_questions'

tbl_questions {question_id (PK) int , question_text nvarchar(max)}



But now you have to change type of question_text to ntext to support multilingual text and also add an additional field for language and also primary key constraint composite of question_id and languaage_id
.

tbl_questions { question_id(PK)  int ,language_id (PK) int, question_text ntext}




Now on you have to save the text in selected language. Which means if you've support for four language then same question text has to save four times against those languages.

So u need to make changes in DB end. Mean while on front end no changes would be required. To render the correct text you have to fetch the data against current selected language.

That's how I achieve multilingual site with resource files and db with ntext field.


这篇关于如何在ASP.NET C#中创建多个语言的网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆