一旦我加入环球资源的语言,我怎么给客户选择哪种语言选择? [英] Once I've added Global Resource languages, how do I give client option which language to choose?

查看:181
本文介绍了一旦我加入环球资源的语言,我怎么给客户选择哪种语言选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加在我公司的网站3其他语言(FR,ES-MX,德)英语,和他们都工作正常。我跟着 MSDN演练打造本地化

I have added 3 additional languages (fr, es-mx, de) to English in my company's website, and they're all working fine. I followed the MSDN walkthrough on creating localization.

我在使用Visual Studio 2010 / VB /点网4.0和我已经在我对我所有的网页最上面一行,这样的:

I'm using Visual Studio 2010 / VB / dot-net 4.0 and I already have in my top line on all of my pages, this:

  <%@ Page Title="USS Products & Services" Language="VB" MasterPageFile="~/products/products.Master" AutoEventWireup="false"
CodeFile="default.aspx.vb" Inherits="default" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>

我有4个全球资源(的.resx)在我的global_apps目录中的文件。但是,如果我不想只是单单的浏览器,以检测他们的语言?我想给他们选择自己的语言的选择。

I have 4 global resource (.resx) files in my global_apps directory. But what if I don't want just the browser alone to detect their language? I want to give them the option of choosing their own language.

我怎么给客户4标志之间的选择 - 1为每种语言 - 并让他们选择呢?或者,也许效果翻车站点地图类型,在那里他们可以将鼠标悬停在语言和选择呢?任何帮助将是AP preciated!谢谢!

How do I give the client the option between 4 flags -- 1 for each language -- and let them choose? Or maybe a rollover sitemap type of effect, where they can mouse over a language and choose it? Any help would be appreciated! Thanks!

推荐答案

试试这个简单的方法: 我已经定义了语言在DropDownList中,有一个按钮,选择

Try this simple method: I've defined the languages in a dropdownlist and have a button select

<asp:DropDownList ID="ddlCulture" DataTextField="DisplayName" DataValueField="Name"
         runat="server" >
        <asp:ListItem Value="es-MX">Spanish</asp:ListItem>
        <asp:ListItem Value="en-US">English</asp:ListItem>
    </asp:DropDownList>
<asp:Button ID="btnSelect" Text="Select" runat="server" OnClick="btnSelect_Click" />

现在code:

protected void btnSelect_Click(object sender, EventArgs e)
   {
        Session["uiculture"] = ddlCulture.SelectedValue;
        Session["culture"] = ddlCulture.SelectedValue;
        Response.Redirect(Request.Path);
   }

    protected override void InitializeCulture()
    {
      if(Session["culture"]!=null)
        UICulture=Session["culture"].ToString();
    }

更新:对不起,我忘了override关键字。现在,包括它应该工作。

Update: Sorry I forgot the override keyword. Now included it should work.

靠,你使用VB的方式,对不起I'vent看到了这一点。等效code是:

By the way, you're using VB, sorry I'vent seen this. The equivalent code is:

 Protected Sub btnSelect_Click(ByVal sender As Object, ByVal e As EventArgs)
    Session("uiculture") = ddlCulture.SelectedValue
    Session("culture") = ddlCulture.SelectedValue
    Response.Redirect(Request.Path)
End Sub
Protected Overrides Sub InitializeCulture()
    If Not Session("culture") Is Nothing Then
        UICulture = Session("culture").ToString()
    End If
End Sub

这篇关于一旦我加入环球资源的语言,我怎么给客户选择哪种语言选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆