简体   繁体   English

一个国家的多语言网站

[英]Multi lingual site for one country

I have a requirement where I have a site and the user enters the product information from an administrative end.我有一个要求,我有一个网站,用户从管理端输入产品信息。

One of the mandatory requests is to select a country for the product before the user can save the product.强制性要求之一是在用户保存产品之前为产品选择一个国家。

When a public user arrives at the site they need to have the option to swap between the languages.当公共用户到达站点时,他们需要选择在语言之间进行切换。 So if I arrived to the German site and want to view the site in English I should be able to change from German to English (and back to German).因此,如果我到达德语站点并想以英语查看该站点,我应该能够从德语更改为英语(然后再更改为德语)。

I have the resource files created (German) however how do I swap between the two languages.我创建了资源文件(德语),但是如何在两种语言之间进行交换。 I appreciate I may need to tweak a little more but if I can get onto the right track I can take it/question from there?我很感激我可能需要再做一些调整,但如果我能走上正确的轨道,我可以从那里接受它/问题吗?

First you ensure you save the data in the correct encoding in your database by configuring the data collation for each language, and save it in the correct datatype.首先,通过为每种语言配置数据collation ,确保以正确的编码将数据保存在数据库中,并将其保存在正确的数据类型中。

To do that you must do the following :为此,您必须执行以下操作:

Database数据库

  • Ensure the column or database collation is defined to the targeted language read more about it SQL Server , Oracle , MySQL确保将列或数据库collation定义为目标语言 阅读有关SQL ServerOracleMySQL 的更多信息
  • Ensure the column datatype is designed to accept Unicode characters.确保列数据类型设计为接受 Unicode 字符。 (if you save some text, it should show it as is). (如果您保存一些文本,它应该按原样显示)。

Application应用

in your ASP.NET Application, you ensure that you read these data from the database with the correct encoding ( UTF-8 is a common encoding for the web, but sometimes you might need to use ASCII or Unicode then convert it back to UTF-8 depends on the language you're dealing with).在您的 ASP.NET 应用程序中,您确保使用正确的编码从数据库读取这些数据( UTF-8是网络的常用编码,但有时您可能需要使用ASCIIUnicode然后将其转换回UTF-8取决于您正在处理的语言)。

After ensuring the string encoding.确保string编码后。 You can now use it on your ASP pages, you only need to control the page language you have two options.您现在可以在您的 ASP 页面上使用它,您只需要控制您有两个选项的页面语言。

Option 1 : Use Javascript to translate the page to another language dynamically using html lang attribute .选项 1:使用Javascript使用html lang 属性将页面动态转换为另一种语言。

Option 2 : Use .NET Globalization by defining the translations using resources files more in that in this link选项 2:通过在此链接中更多地使用资源文件定义翻译来使用 .NET Globalization

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM