Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2007, 01:15 PM
Authorized User
 
Join Date: Dec 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use different Controls for different language?

Hi,

Let say we have a menu in french and in english. That menu is contained inside a control.

They are different enough that we cannot localize one version for both language, we actually need to have to separate control. For example: MenuFrench.ascx and MenuEnglish.ascx.

So, in our MasterPage. We want to plug the right control depending on the language setting. How can we do that?

Thank you!

 
Old April 1st, 2007, 01:34 AM
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I used the following code to handle localization in english and arabic applications, it is working

Protected Sub Page_PreInit( _
          ByVal sender As Object, ByVal e As System.EventArgs) _
          Handles Me.PreInit
        Dim chooselang As String
        chooselang = Request("CultureChoice")
        If Trim(chooselang) <> "" Then
            Application("CultureChoice") = chooselang
        Else
            chooselang = Application("CultureChoice")
            If Trim(chooselang) = "" Then
                chooselang = "en-US"
            End If
        End If
        Dim lang As System.Globalization.CultureInfo
        If chooselang = "ar-KW" Then
            MasterPageFile = "MasterPageA.master"
        Else
            MasterPageFile = "MasterPage.master"
        End If
        lang = New System.Globalization.CultureInfo(chooselang)
        System.Threading.Thread.CurrentThread.CurrentUICul ture = lang
    End Sub


Where one of the Master Pages will Contain the english menu and the other will contain french menu


while the following should be contained in the culturechooser.aspx.vb
Imports System.Data
Imports System.Globalization

Partial Class culturechooser
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim culture As CultureInfo
        Dim str As String
        str = Request.QueryString("CultureChoice")
        culture = CultureInfo.CreateSpecificCulture(str)
        Dim cookie As HttpCookie
        cookie = New HttpCookie("CulturePref", culture.Name)

        cookie.Expires = DateTime.Now.AddYears(100)
        Response.Cookies.Add(cookie)

        Dim chooselang As String
        chooselang = Trim(Application("CultureChoice"))
        If chooselang = "ar-KW" Then
            chooselang = "en-US"
        Else
            chooselang = "ar-KW"
        End If

    End Sub
End Class

have a nice day






Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls on the fly language rulllesss XML 0 June 9th, 2008 09:16 AM
I need some help with C language ranifrah Visual C++ 2005 1 May 12th, 2008 03:34 AM
Which language is better? sario777 VS.NET 2002/2003 4 April 17th, 2005 01:35 PM
C language krbhatnagar C++ Programming 2 December 22nd, 2004 05:59 AM
c language help!!! kernel_zap C# 2 April 29th, 2004 09:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.