Culture. What am I doing wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Culture. What am I doing wrong?

    Hello,

    I am initializing the culture of a page as follows:

    protected override void InitializeCultu re() {
    base.Initialize Culture();
    CultureInfo culture = Profile.Get().V isitor.Culture;
    if (culture == null) culture = default(Culture Info);
    Thread.CurrentT hread.CurrentCu lture = culture;
    Thread.CurrentT hread.CurrentUI Culture = culture;
    }

    Basically, my objective is to get the culture from Visitor property in
    profile. If it is null then use the default culture in Web.Config:

    <globalizatio n
    culture="auto:p t-PT"
    uiCulture="auto :pt-PT"/>

    The problem is that when the culture is null in profile I always get
    "en-US".

    What am I doing wrong?

    Thanks,

    Miguel
  • rstrahl

    #2
    Re: Culture. What am I doing wrong?

    Hi Miguel,

    Your problem is default( CultureInfo ) which gives null. You should use new
    CultureInfo("pt-PT"); or better yet:

    culture = CultureInfo.Cur rentCulture;

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies





    "shapper" <mdmoura@gmail. comwrote in message
    news:a3f7c1d8-1706-4d4e-8bc7-be6c1240f3c9@v2 8g2000hsv.googl egroups.com...
    Hello,
    >
    I am initializing the culture of a page as follows:
    >
    protected override void InitializeCultu re() {
    base.Initialize Culture();
    CultureInfo culture = Profile.Get().V isitor.Culture;
    if (culture == null) culture = default(Culture Info);
    Thread.CurrentT hread.CurrentCu lture = culture;
    Thread.CurrentT hread.CurrentUI Culture = culture;
    }
    >
    Basically, my objective is to get the culture from Visitor property in
    profile. If it is null then use the default culture in Web.Config:
    >
    <globalizatio n
    culture="auto:p t-PT"
    uiCulture="auto :pt-PT"/>
    >
    The problem is that when the culture is null in profile I always get
    "en-US".
    >
    What am I doing wrong?
    >
    Thanks,
    >
    Miguel

    Comment

    Working...