Localization: user selectable UICulture w/ UICulture = auto

Discussion in 'ASP .Net' started by =?Utf-8?B?U2FtdWVs?=, Aug 6, 2005.

  1. Hi,

    I am running into a problem of mixing UICulture = auto and allowing users to
    select culture using a dropdown list.

    I am detecting a querystring, "setlang", and when found, setting the
    CurrentUICulture to what's specified in the querystring. Since I want to
    allow UICulture auto detecting, I add UICulture = "auto" to page directive on
    each page.

    Now, here is the problem: I don't know on what event (page or application) I
    should set the CurrentUICulture based on the querystring, "setlang".

    Since the UICulture = "auto", I cannot utilize any of the application events
    to set CurrentUICulture. I could use PostAcquireRequestState if UICulture is
    not auto on in page directive.

    I cannot use page event effectively either. I tried to set CurrentUICulture
    based on querystring in Page.PreInit. It seems that if I programmatically set
    control's text to a resource string (textbox1.text =
    resources.language.astring) everything works fine, but if I use explicit
    binding declaratively on the control (<%$ Resources: language, astring%>), it
    ignores the CurrentUICulture set in Page.PreInit and displays the string from
    the culture the page auto detects. Not being able to bind declaratively is a
    produtivity killer and therefore not acceptable.

    Can anyone shed some light on how I can accomplish this?
    I will repeat what I want to accomplish:

    1) UICulture = "auto" on page directive (or can I set it somewhere else?)
    2) user selectable cultures
    3) being able to bind resources to control declaratively (<%$ Resources:
    language, astring%>)
     
    =?Utf-8?B?U2FtdWVs?=, Aug 6, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?U2FtdWVs?=

    Guest

    Hi Samuel,

    I think the last section of this blog post can help you :
    http://dotnetjunkies.com/WebLog/anoras/archive/2005/02/13/54271.aspx

    Let me know if you have any more questions..

    Cheers,
    Tom Pester

    > Hi,
    >
    > I am running into a problem of mixing UICulture = auto and allowing
    > users to select culture using a dropdown list.
    >
    > I am detecting a querystring, "setlang", and when found, setting the
    > CurrentUICulture to what's specified in the querystring. Since I want
    > to allow UICulture auto detecting, I add UICulture = "auto" to page
    > directive on each page.
    >
    > Now, here is the problem: I don't know on what event (page or
    > application) I should set the CurrentUICulture based on the
    > querystring, "setlang".
    >
    > Since the UICulture = "auto", I cannot utilize any of the application
    > events to set CurrentUICulture. I could use PostAcquireRequestState if
    > UICulture is not auto on in page directive.
    >
    > I cannot use page event effectively either. I tried to set
    > CurrentUICulture based on querystring in Page.PreInit. It seems that
    > if I programmatically set control's text to a resource string
    > (textbox1.text = resources.language.astring) everything works fine,
    > but if I use explicit binding declaratively on the control (<%$
    > Resources: language, astring%>), it ignores the CurrentUICulture set
    > in Page.PreInit and displays the string from the culture the page auto
    > detects. Not being able to bind declaratively is a produtivity killer
    > and therefore not acceptable.
    >
    > Can anyone shed some light on how I can accomplish this? I will repeat
    > what I want to accomplish:
    >
    > 1) UICulture = "auto" on page directive (or can I set it somewhere
    > else?)
    > 2) user selectable cultures
    > 3) being able to bind resources to control declaratively (<%$
    > Resources:
    > language, astring%>)
     
    , Aug 6, 2005
    #2
    1. Advertising

  3. Hi Tom,

    Thanks for your reply. Actually what's in the blog is what I did in my code
    already. The only difference is that he uses PreRequestHandlerExecute and I
    used PostAcquireRequestState (no difference)

    However, I found the solution: if you want uiculture=auto while still
    allowing user to change uiculture, the only way is to set uiculture = auto in
    web.config and not on the page. When uiculture = auto is set in web.config,
    we can use application event to override it, but when uiculture=auto is set
    in page directive, you cannot override it for declaratively bound resources.

    "" wrote:

    > Hi Samuel,
    >
    > I think the last section of this blog post can help you :
    > http://dotnetjunkies.com/WebLog/anoras/archive/2005/02/13/54271.aspx
    >
    > Let me know if you have any more questions..
    >
    > Cheers,
    > Tom Pester
    >
    > > Hi,
    > >
    > > I am running into a problem of mixing UICulture = auto and allowing
    > > users to select culture using a dropdown list.
    > >
    > > I am detecting a querystring, "setlang", and when found, setting the
    > > CurrentUICulture to what's specified in the querystring. Since I want
    > > to allow UICulture auto detecting, I add UICulture = "auto" to page
    > > directive on each page.
    > >
    > > Now, here is the problem: I don't know on what event (page or
    > > application) I should set the CurrentUICulture based on the
    > > querystring, "setlang".
    > >
    > > Since the UICulture = "auto", I cannot utilize any of the application
    > > events to set CurrentUICulture. I could use PostAcquireRequestState if
    > > UICulture is not auto on in page directive.
    > >
    > > I cannot use page event effectively either. I tried to set
    > > CurrentUICulture based on querystring in Page.PreInit. It seems that
    > > if I programmatically set control's text to a resource string
    > > (textbox1.text = resources.language.astring) everything works fine,
    > > but if I use explicit binding declaratively on the control (<%$
    > > Resources: language, astring%>), it ignores the CurrentUICulture set
    > > in Page.PreInit and displays the string from the culture the page auto
    > > detects. Not being able to bind declaratively is a produtivity killer
    > > and therefore not acceptable.
    > >
    > > Can anyone shed some light on how I can accomplish this? I will repeat
    > > what I want to accomplish:
    > >
    > > 1) UICulture = "auto" on page directive (or can I set it somewhere
    > > else?)
    > > 2) user selectable cultures
    > > 3) being able to bind resources to control declaratively (<%$
    > > Resources:
    > > language, astring%>)

    >
    >
    >
     
    =?Utf-8?B?U2FtdWVs?=, Aug 6, 2005
    #3
  4. Hi Samuel,

    I've also got the result you mentioned on my local enviornment.
    =================
    if you want uiculture=auto while still
    allowing user to change uiculture, the only way is to set uiculture = auto
    in
    web.config and not on the page. When uiculture = auto is set in web.config,
    we can use application event to override it, but when uiculture=auto is set
    in page directive, you cannot override it for declaratively bound resources.
    ================

    I think the difference between the UICulture in @page directive and
    web.config maybe the @Page directive's setting will be forced in some
    internal time during the page's processing which makes our adjusting in
    application level event be overrided. Anyway, IMO, we'd recommend that we
    avoiding using the "Auto" setting together with custom culture handling ,
    thus there will exist no such potiential conflict.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | Thread-Topic: Localization: user selectable UICulture w/ UICulture = auto
    | thread-index: AcWavK9UvxFPttTERyG0bfUj0lZGdw==
    | X-WBNR-Posting-Host: 64.180.16.145
    | From: =?Utf-8?B?U2FtdWVs?= <>
    | References: <>
    <>
    | Subject: Re: Localization: user selectable UICulture w/ UICulture = auto
    | Date: Sat, 6 Aug 2005 12:26:03 -0700
    | Lines: 64
    | Message-ID: <>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:116515
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Hi Tom,
    |
    | Thanks for your reply. Actually what's in the blog is what I did in my
    code
    | already. The only difference is that he uses PreRequestHandlerExecute and
    I
    | used PostAcquireRequestState (no difference)
    |
    | However, I found the solution: if you want uiculture=auto while still
    | allowing user to change uiculture, the only way is to set uiculture =
    auto in
    | web.config and not on the page. When uiculture = auto is set in
    web.config,
    | we can use application event to override it, but when uiculture=auto is
    set
    | in page directive, you cannot override it for declaratively bound
    resources.
    |
    | "" wrote:
    |
    | > Hi Samuel,
    | >
    | > I think the last section of this blog post can help you :
    | > http://dotnetjunkies.com/WebLog/anoras/archive/2005/02/13/54271.aspx
    | >
    | > Let me know if you have any more questions..
    | >
    | > Cheers,
    | > Tom Pester
    | >
    | > > Hi,
    | > >
    | > > I am running into a problem of mixing UICulture = auto and allowing
    | > > users to select culture using a dropdown list.
    | > >
    | > > I am detecting a querystring, "setlang", and when found, setting the
    | > > CurrentUICulture to what's specified in the querystring. Since I want
    | > > to allow UICulture auto detecting, I add UICulture = "auto" to page
    | > > directive on each page.
    | > >
    | > > Now, here is the problem: I don't know on what event (page or
    | > > application) I should set the CurrentUICulture based on the
    | > > querystring, "setlang".
    | > >
    | > > Since the UICulture = "auto", I cannot utilize any of the application
    | > > events to set CurrentUICulture. I could use PostAcquireRequestState if
    | > > UICulture is not auto on in page directive.
    | > >
    | > > I cannot use page event effectively either. I tried to set
    | > > CurrentUICulture based on querystring in Page.PreInit. It seems that
    | > > if I programmatically set control's text to a resource string
    | > > (textbox1.text = resources.language.astring) everything works fine,
    | > > but if I use explicit binding declaratively on the control (<%$
    | > > Resources: language, astring%>), it ignores the CurrentUICulture set
    | > > in Page.PreInit and displays the string from the culture the page auto
    | > > detects. Not being able to bind declaratively is a produtivity killer
    | > > and therefore not acceptable.
    | > >
    | > > Can anyone shed some light on how I can accomplish this? I will repeat
    | > > what I want to accomplish:
    | > >
    | > > 1) UICulture = "auto" on page directive (or can I set it somewhere
    | > > else?)
    | > > 2) user selectable cultures
    | > > 3) being able to bind resources to control declaratively (<%$
    | > > Resources:
    | > > language, astring%>)
    | >
    | >
    | >
    |
     
    Steven Cheng[MSFT], Aug 8, 2005
    #4
  5. Thanks Steven for your reply. Yes, I think the same too, but I also think
    that being able to auto select UIculture for users while allowing them to
    choose ui is a very nice feature if you want pefect globalization for your
    app. Thus, setting UICulture = auto in web.config seems like a good solution
    to me.. are you telling me you are afraid that in the future this behavior
    could change?

    By the way, can you please check out this new thread of mine, titled

    "reference web control in dynamically added user control, ASP.NET 2"

    I am not sure how I can send you directly the URL to the post, but you
    should be able to see it on the first page of this newsgroup.

    Thanks in advance!
     
    =?Utf-8?B?U2FtdWVs?=, Aug 8, 2005
    #5
  6. Thanks for your prompt response Samuel,

    En, yes, though I'm not absolutely sure whether this is changable through
    different version, but since its a undocumented behavior, generally we can
    not guarantee it. Anyway, I think its ok that you leave it as you currently
    do.

    In addition, as for the new thread you mentioned, did you just post it
    right now? If so, maybe it hasn't been synchornized to our internal
    program, I also search it on google and didn't find it. I'll monitor it
    later. In addition, for asp.net 2.0 issue, we also suggest you try posting
    in the

    http://forums.microsoft.com/msdn/default.aspx

    msdn forum since sometimes there have some .net dev team's members there.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)


    --------------------
    | Thread-Topic: Localization: user selectable UICulture w/ UICulture = auto
    | thread-index: AcWb7IYdiCzNB71iQhCmuDCyCAh4fg==
    | X-WBNR-Posting-Host: 64.180.16.145
    | From: =?Utf-8?B?U2FtdWVs?= <>
    | References: <>
    <>
    <>
    <BQWi7i#>
    | Subject: Re: Localization: user selectable UICulture w/ UICulture = auto
    | Date: Mon, 8 Aug 2005 00:41:01 -0700
    | Lines: 15
    | Message-ID: <>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:116630
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Thanks Steven for your reply. Yes, I think the same too, but I also think
    | that being able to auto select UIculture for users while allowing them to
    | choose ui is a very nice feature if you want pefect globalization for
    your
    | app. Thus, setting UICulture = auto in web.config seems like a good
    solution
    | to me.. are you telling me you are afraid that in the future this
    behavior
    | could change?
    |
    | By the way, can you please check out this new thread of mine, titled
    |
    | "reference web control in dynamically added user control, ASP.NET 2"
    |
    | I am not sure how I can send you directly the URL to the post, but you
    | should be able to see it on the first page of this newsgroup.
    |
    | Thanks in advance!
    |
     
    Steven Cheng[MSFT], Aug 8, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henke
    Replies:
    5
    Views:
    4,755
    shailpatel83
    Feb 24, 2010
  2. =?ISO-8859-1?Q?Roland_M=FCller?=
    Replies:
    1
    Views:
    1,637
    =?ISO-8859-1?Q?Roland_M=FCller?=
    Nov 21, 2005
  3. Replies:
    4
    Views:
    11,394
    =?Utf-8?B?RGF2?=
    Jul 10, 2006
  4. Klaus Jensen

    Setting UIculture in code

    Klaus Jensen, Jun 15, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    532
    Brock Allen
    Jun 17, 2006
  5. linkswanted
    Replies:
    1
    Views:
    952
Loading...

Share This Page