简体   繁体   中英

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.

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
  • Ensure the column datatype is designed to accept Unicode characters. (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).

After ensuring the string encoding. You can now use it on your ASP pages, you only need to control the page language you have two options.

Option 1 : Use Javascript to translate the page to another language dynamically using html lang attribute .

Option 2 : Use .NET Globalization by defining the translations using resources files more in that in this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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