ASP.NET Web Page Multilingual Support Solutions

xiaoxiao2021-03-06  58

Column of Johnlen http://blog.9cbs.net/johnlen

Copyright Notice: 9CBS is this BLOG managed service provider. If this paper involves copyright issues, 9CBS does not assume relevant responsibilities, please contact the copyright owner directly with the article Author.

First establish language files, join .equiry, for example: message.zh-cn.resx 'simplified Chinese message.zh-tw.resx' Traditional Chinese Message.en ???????? 'English ... ...........

============================================================================================================================================================================================================= ==================== Then use the Name -Value key value to fill in the language you want to display on the page, such as: ????????? ????????????????????????????????????????????? Value message.zh-cn.resx: ??????????????????????????????????????????????????????????????????????????????????????????????? ???????? login name: message.zh-tw.resx: ?????????????????????? ???????? res_loginbname ??????????? login name: message.zh-cn.resx: ????????????????????????????????????????????? ????????????????????? res_loginbname ??????????? Login Name:

?

============================================================================================================================================================================================================= ==================== Then add multilingual setting support code in Golbal.asax (the browser needs to support cookies)

??? '=============================================== ===============================================??? 'Application_BeginRequest Event ???' ??? 'The Application_BeginRequest method is an ASP.NET event that executes ???' on each web request into the portal application.? ??? '???' The thread culture is set for Each Request Using The Language ??? 'settings ???' ??? '=================================================================================================================================================================================================================================== ============================================================================================================================================================================================================= =========== ??? SUB Application_BeginRequest (Byval e AS Object, BYVAL E as Eventargs) ??????? Try ???????????i NOT REQUEST. Cookies ("resource") is nothing or request.cookies ("resource"). Value = "" "??????????????? thread.currentthread.currentculture = CultureInfo.createspecificCulture (Request. Cookies ("resource"). Value) ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Thread.currentthread.currentculture = new cultureInfo (configurationSettings.appsettings)

DEFAULTCULTURE ") ?????????????????????????? threaduicultuicultuiculture = thread.currentthread.currentculture ??????? Catch EX As Exception ??????????? Thread.CurrentThread.CurrentCulture = New CultureInfo (ConfigurationSettings.AppSettings ( "DefaultCulture")) ??????? End Try ??? End Sub 'Application_BeginRequest in Web.Config Add the following code to set the encoding and default language, there is called in global.asax:

============================================================================================================================================================================================================= ====================???

???????

???????????????

???????????????

???????

??????

?

============================================================================================================================================================================================================= ==================== Using multilingual support in page code:

Imports system.resources

Public Class Your class name ??? inherits system.web.ui.page ??? protected loCRM As ResourceManager = New ResourceManager ("Project File Name .message", GetType (class name) .assembly

??? private sub page_load (Byval e as system.EventArgs) handles mybase.load ??????? lbllogin.text = LoCrm.getstring ("res_login") ??? End Subend Class

============================================================================================================================================================================================================= ==================== Go to the work of multilingual support, let go of yourself, KeyMessage.zh-cn.resx 'simplified Chinese Message.zh -tw.resx 'Traditional Chinese MESSAGE.EN ????????

These languages, this is a painful memory!

The suffix of language such as: zh-CN 'Simplified Chinese en-TW' Traditional Chinese En ??

Can refer to IE Options - Network Settings -> General Tab Language -> Content

转载请注明原文地址:https://www.9cbs.com/read-117038.html

New Post(0)