Re: where to set the current culture in ASP.NET 2.0?



If you add Culture="auto" UICulture="auto" to the page directive and an
American user logs when his/her browser setting is “en-US” then they would
not need to select the language of their preference unless they want to
switch to a language that is not in the first selection in their browser
setting. You can then add a link that says “Select language of preference”
which would save the selection in a cookie and upon next visit the master
page would simply execute Page.Culture=selectedCulture if there were a
cookie. This would last longer than using the Session object which expires
when the browser is closed or the Session expired (in which scenario the user
has to select the culture upon every visit)
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Edge" wrote:

> hi Phillip,
> because for example, in a chinese cybercafe I want a american user to login
> in our system and be able to choose his preferred language just once and
> then this selection to be applied in all the other pages.
> I tried your suggestion but, I do not want to put in every single page code
> like Page.Culture = "en-us".
>
> -E
>
>
>
>
> "Phillip Williams" <Phillip.Williams@xxxxxxxxxxxx> wrote in message
> news:433466A6-D313-4ACC-A9E9-E073B38C24EB@xxxxxxxxxxxxxxxx
> > Why not use the user's browser settings upon each postback instead? You
> > can
> > set Culture="auto" UICulture="auto" on the page directive, e.g.:
> > http://www.webswapp.com/CodeSamples/aspnet20/AutoCulture.aspx
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Edge" wrote:
> >
> >> hi,
> >> I am saving the user selected culture in a session variable so I can
> >> apply
> >> it back to all pages when refreshed and then load the proper .resx
> >> values.
> >> For that I am using global.asax, Application_AcquireRequestState, because
> >> every page load will execute this method.
> >> Even thou it works, very often I get en exception telling that the
> >> session
> >> can not be retrieved in this context.
> >>
> >> What's the best place to actually place this verification in order to be
> >> reflected in every page of my application?
> >> here the global.asax code
> >>
> >> public void Application_AcquireRequestState(object sender, EventArgs e)
> >> {
> >>
> >> if ( Session["myculture"] != null )
> >> {
> >> string currentCulture = (string)Session["myculture"];
> >> if (String.Compare(currentCulture,
> >> System.Threading.Thread.CurrentThread.CurrentCulture.ToString(),
> >> StringComparison.OrdinalIgnoreCase) != 0)
> >> {
> >> try
> >> {
> >> System.Threading.Thread.CurrentThread.CurrentCulture
> >> =
> >> System.Globalization.CultureInfo.CreateSpecificCulture(currentCulture);
> >> }
> >> catch
> >> {
> >> System.Threading.Thread.CurrentThread.CurrentCulture
> >> =
> >> new System.Globalization.CultureInfo("en-us");
> >> }
> >> System.Threading.Thread.CurrentThread.CurrentUICulture =
> >> System.Threading.Thread.CurrentThread.CurrentCulture;
> >> }
> >> }
> >> }
> >>
> >>
> >>
>
>
>
.



Relevant Pages

  • Re: Both SAT and AAT have failed
    ... water was involved with the selection of language. ... voluntary breathing, ... Biological evolution is based on evolutionary theory the central ...
    (sci.anthropology.paleo)
  • Re: Both SAT and AAT have failed
    ... water was involved with the selection of language. ... voluntary breathing, ... hyper-ventilation were preadaptations to voluntary breathing control for ...
    (sci.anthropology.paleo)
  • Re: Which Is The Better Approach To Working With Javascript?
    ... Java SCRIPT runs in the browser exclusively. ... No language is written just for a single environment. ... You have to understand that I come from a hardware background, a huge area that is complately unknown to most 'computer programmers' whose life begins and ends with an interpreter or compiler.. ...
    (comp.lang.php)
  • Re: Non-linear transfer function of a cat and mouse in Laplace domain.
    ... "Natural Selection" as a single phrase on the blackboard while you sat ... This inability to discern SA has lead to the pragmatics communicated ... would influence your general aphobetics you have with language itself. ...
    (talk.origins)
  • Re: The Paradox of Speciation
    ... compatibility can build up over time into big changes that do. ... The selection pressures ... French is the product of intelligent design, ... let me switch to any other language. ...
    (talk.origins)

Loading