>Check where you have the resource files. It matters.
>of linking to local/global resources.
>posts.
>Gregory A. Beamer
>news:uDaxwSDiHHA.872@TK2MSFTNGP03.phx.gbl...
Quote:
>>I am trying to localize a very simple web site (english and french)
>>>
>>I have a master page and one content page for now.
>>On the master page I have placed a Localize control
>>>
>>On the content page I have placed a label and a dropdownlist. The label
>>says "Use this language" or "Utilisez cette laague"
>>The dropdownlist Contains values "en-US" text Englsih Us and "fr-CA" text
>>"French Canada)
>>>
>>I have resource files for the master page in english and french with a
>>key saying "welcome" value Welcome in english and Bienvenue in french
>>resource file. They are local resource files for the master.
>>>
>>The objective is to allow the user to switch languages by settting the
>>current threads UiCulture and Culture in code when the user selects
>>another language. When he -she changes language in the dropdown list ,
>>the content of the master file localize control should change and the
>>contents of the content page should change.
>>>
>>I've been f.. around with this one for over two days but I can't get it
>>working.
>>I have based my code on the code in the sample video on msdn for
>>localization but in this case just extending it to work with a master
>>page I've hit a brick wall :-(
>>>
>>Can someone PLEASE, prety please give a hand on this one.
>>>
>>This is the code I've come up with so far
>>>
>>1- the master page, just a standard masterpage with one localized control
>>on it.
>>>
>><%@ Master Language="VB" %>
>>>
>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>
>><script runat="server">
>>>
>></script>
>>>
>><html xmlns="http://www.w3.org/1999/xhtml">
>>>
>><head runat="server">
>>>
>><title>Untitled Page</title>
>>>
>></head>
>>>
>><body>
>>>
>><form id="form1" runat="server">
>>>
>><div>
>>>
>><asp:Localize ID="LocWelc" runat="server" meta:resourcekey="Welcome"
>>Text="Welcome"></asp:Localize><br />
>>>
>><asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
>>>
>></asp:ContentPlaceHolder>
>>>
>></div>
>>>
>></form>
>>>
>></body>
>>>
>></html>
>>>
>>>
>>>
>>2- The content page - standard page with default culture and Uiculture
>>set tp fr-CA
>>>
>><%@ Page Language="VB" MasterPageFile="~/Site.master"
>>AutoEventWireup="false" CodeFile="Default3.aspx.vb"
>>>
>>Inherits="Default3" Title="Untitled Page" Culture="fr-CA"
>>UICulture="fr-CA"%>
>>>
>><%-- Add content controls here --%>
>>>
>><asp:Content runat="server" ID="d3C"
>>ContentPlaceHolderID="ContentPlaceHolder1"
>>>
>>EnableViewState="true">
>>>
>><asp:Label ID="Label1" runat="server" Text="<%$ Resources:Label1.Text
>>%>"></asp:Label>
>>>
>><asp:DropDownList ID="Language1" runat="server" AutoPostBack="True"
>>Width="149px">
>>>
>><asp:ListItem Value="fr-CA">Français (Canada)</asp:ListItem>
>>>
>><asp:ListItem Value="fr-FR">Français (France)</asp:ListItem>
>>>
>><asp:ListItem Value="en-CA">English (Canada)</asp:ListItem>
>>>
>><asp:ListItem Value="en-US">English (US)</asp:ListItem>
>>>
>></asp:DropDownList>
>>>
>></asp:Content>
>>>
>>>
>>>
>>3- The code behind of the content page
>>>
>>Imports System.Threading
>>>
>>Imports System.Globalization
>>>
>>Partial Class Default3
>>>
>>Inherits System.Web.UI.Page
>>>
>>Protected Overrides Sub InitializeCulture()
>>>
>>If Request.Form.Item("Language1") IsNot Nothing Then
>>>
>>Dim Lang As String = Request.Form.Item("language1")
>>>
>>Thread.CurrentThread.CurrentCulture = _
>>>
>>CultureInfo.CreateSpecificCulture(Lang)
>>>
>>Thread.CurrentThread.CurrentUICulture = New _
>>>
>>CultureInfo(Lang)
>>>
>>End If
>>>
>>End Sub
>>>
>>End Class
>>>
>>All the controls on both master and content page have had their
>>expressions text property set to point to the appropriate key in the
>>resource file.
>>>
>>The main problem appears to be that no matter what, when I change the
>>selection in the drop down list the variable
>>Request.Form.Item("Language1") always returns nothing I can never obtain
>>the value of the dropdownlist selected item.
>>>
>>I can get it to detect the selected language if I detect it in the
>>selected index changed event of the language1 control but this event
>>fires well after the Initialize culture event, so If I use that I am
>>always using the previously selected item not the one that is currently
>>being selected.
>>>
>>The technique described above with the code in the code behind works OK
>>in a stand alone content page but it fails miserably when you make a
>>content page that uses a master page. I have not been able to find any
>>sample code on how to use this with master pages.
>>>
>>The second part of the question, sorry if its long, is how do you change
>>the value of the localize control on the master page when the user
>>selects another language in the content page?
>>>
>>I am realy desperate and would really appreciate any help anyone would be
>>kind enough to give
>>>
>>Thanks you in advance to all
>>>
>>Bob
>>>
>>>