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 英文

    这几个语言档吧
  • 相关阅读:
    全排列和全组合实现
    (原)关于MEPG-2中的TS流数据格式学习
    linux的PAM认证和shadow文件中密码的加密方式
    vim 撤销 回退操作
    memcached解压报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now的解决方法
    Linux系统安全之pam后门安装使用详解
    漏洞预警:Linux内核9年高龄的“脏牛”0day漏洞
    linux软链接的创建、删除和更新
    关于“.bash_profile”和“.bashrc”区别的总结
    linux下批量杀死进程
  • 原文地址:https://www.cnblogs.com/luluping/p/1433118.html
Copyright © 2011-2022 走看看