Allowing .NET MVC (C#) Web Application accept foreign languages
I have a web application written in .NET MVC (C#). Currently my web app allows the user to enter information to the system using textboxes, etc, store it in a database, and view this information on a webpage (view) - all in English.
I was wondering what would be inv开发者_开发技巧olved to allow my users enter information (and subsequently view it) in a foreign language (European languages - Spanish, French, German, Portugese, etc).
Any help or pointers is appreciated.
Thanks!
If you want to localize your application you may take a look at the following article. As far as allowing users to enter information in different languages is concerned, well, a textbox is a textbox, a user can enter whatever he wants and a database is a database, it can store everything you throw it, it doesn't really care whether it's English, French or Klingon.
So based on the Thread.CurrentThread.CurrentUICulture
you will know what language is being used and organize your models respectively.
As far as storing the current user language preference is concerned you have multiple choices: cookies, route parameters, session, ...
Are you looking to store international information or translate your current page's text into another language?
For storing input in different languages, use the nvarchar
flavor of column type to store unicode data
For translation of your site look into localization
If you are only talking about ENTERING data, then you're pretty much set already: The .net Framework is Unicode front to back, so it should just work.
The one thing to make sure is that your database supports foreign characters. In case of Microsoft SQL Server, it's important to use nvarchar/nchar instead of varchar/char columns.
You're looking for something called localization. There are a lot of resources out there, but this might get you started (found that in another question here in SO related to localizing MVC apps).
精彩评论