zoukankan      html  css  js  c++  java
  • WEB页面多语言支持解决方案

    首先建立语言档,在项目中加入.resx文件
    例如:
    message.zh-cn.resx 简体中文
    message.zh-tw.resx 繁体中文
    message.en 英文
    ..............

    ======================================================================
    然后利用name --value 键值对 填入你要在页面上显示的语言
    如:
    name value
    message.zh-cn.resx中:
    res_loginbname 登陆名 :
    message.zh-tw.resx中:
    res_loginbname 登陸名 :
    message.zh-cn.resx中:
    res_loginbname login name :



    ======================================================================
    然后在golbal.asax中加入多语言设定支持代码(浏览器需要支持cookie)

    =============================================================================================
    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 sender as object, byval e as eventargs)
    try
    if not request.cookies("resource") is nothing or request.cookies("resource").value = "" then
    thread.currentthread.currentculture = cultureinfo.createspecificculture(request.cookies("resource").value)
    else
    thread.currentthread.currentculture = new cultureinfo(configurationsettings.appsettings("defaultculture"))
    end if
    thread.currentthread.currentuiculture = thread.currentthread.currentculture
    catch ex as exception
    thread.currentthread.currentculture = new cultureinfo(configurationsettings.appsettings("defaultculture"))
    end try
    end sub application_beginrequest

    在web.config中加入如下代码,用于设定编码和默认语种,在global.asax中有调用:

    ======================================================================
    <globalization requestencoding="utf-8" responseencoding="utf-8" />
    <appsettings>
    <add key="defaultculture" value="zh-cn" />
    <!-- zh-cn:簡體中文 zh-tw:繁體中文 en:英文 -->
    </appsettings>



    ======================================================================
    页面代码中使用多语言支持:

    imports system.resources

    public class 类名
    inherits system.web.ui.page
    protected locrm as resourcemanager = new resourcemanager("项目文件名.message", gettype(类名).assembly)

    private sub page_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load
    lbllogin.text = locrm.getstring("res_login")
    end sub
    end class


    ======================================================================

    到这里多语言支持的工作就作完了,接下来自己去慢慢key
    message.zh-cn.resx 简体中文
    message.zh-tw.resx 繁体中文
    message.en 英文

    这几个语言档吧
  • 相关阅读:
    oracle的安装与plsql的环境配置
    Working with MSDTC
    soapui-java.lang.Exception Failed to load url
    Oracle 一个owner访问另一个owner的table,不加owner
    Call API relation to TLS 1.2
    Call API HTTP header Authorization: Basic
    VS2008 .csproj cannot be opened.The project type is not supported by this installat
    The changes couldn't be completed.Please reboot your computer and try again.
    Create DB Table View Procedure
    DB Change
  • 原文地址:https://www.cnblogs.com/luluping/p/1433118.html
Copyright © 2011-2022 走看看