Method 1: I read some methods on the Internet and thought the method below is quite good. However, in vs2008, I couldn't find the "tools-> generate local resource"
". In addition, you can provide some suggestions on how to make this interface more practical and simple.
1. Make the interface the same way as before, just note that use label to make all the text that requires a multilingual interface
2. After finishing, select this file in Solution Explorer and select Tools> generate local resource.
3. You will find that a directory named app_localresources; contains an additional resx file. For example, if your Aspx file is default. aspx, it will generate a file named default. aspx. resx.
4. open the file and check that all the text in the label has come here.
5. Open the original aspx file and check the source code. The source code is changed:
Method 2: I think this is actually not very good... the generated page basically corresponds to a resource file... It is not very well maintained.
You can write a public method to obtain multiple languages:
Public static string gettext (string name)
{
Return labels. ResourceManager. getstring (name );
}
Labels is the class generated by the created resource file.
In this case, you can directly set the settings where you need to set multiple languages:
For example, <a href = ""> <% = gettext ("Link") %> </a>
Background code:
This. button1.text = gettext ("OK ");
And so on ..
Set the current language environment by selecting a multi-language event during the renewal or login on the page:
For example, in application_beginrequest
String Language = request. Cookies ["language"] = NULL? Null: request. Cookies ["language"]. value;
If (! String. isnullorempty (language ))
{
System. Globalization. cultureinfo culture = new system. Globalization. cultureinfo (language );
System. Threading. thread. currentthread. currentuiculture = culture;
System. Threading. thread. currentthread. currentculture = culture;
}