Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • WG 2 posts 23 karma points
    Aug 05, 2010 @ 11:21
    WG
    1

    Usercontrol localization

    Hi Everyone!

    Now I try to describe my problem... Hope somebody can help me!

    I need to localize asp.net user control, which used on one of umbraco pages. I have almost no experience in development for umbraco, so I tried to localize it in .NET way.

    In MyControl.ascx markup:

    <asp:Localize meta:resourcekey="Title" runat="server"/> 

    And in behind code:

     protected void Page_Load(object sender, EventArgs e)
    {
    var language = page.Request.QueryString.Get(GeneralResources.LanguageParam);

    // if no 'lang' param in request then try to get it from session
    if (String.IsNullOrEmpty(language))
    {
    language = (string)page.Session[GeneralResources.LanguageParam];
    }

    CultureInfo culture;
    string cultureString;
    switch (language)
    {
    case GeneralResources.DeValue:
    culture = CultureInfo.CreateSpecificCulture("de-DE");
    cultureString = "de-DE";
    break;
    case GeneralResources.DaValue:
    culture = CultureInfo.CreateSpecificCulture("da-DK");
    cultureString = "da-DK";
    break;
    default:
    culture = CultureInfo.CreateSpecificCulture("en-US");
    cultureString = "en-US";
    break;
    }
    Thread.CurrentThread.CurrentCulture = culture;
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureString);
    page.Culture = cultureString;
    page.UICulture = cultureString;

    LanguageLabel.Text = "UICulture: " + Page.UICulture;
    LanguageLabel.Text += ". Culture: " + Page.Culture;
    //...
    }

    There are files MyControl.ascx.resx, MyControl.ascx.de-DE.resx, MyControl.ascx.en-US.resx MyControl.ascx.da-DK.resx in App_LocalResources folder.

    LanguageLabel on page shows right culture, but localized values load from MyControl.ascx.resx. If I delete MyControl.ascx.resx then no text is showing on page at all!

    Can anybody show a mistake in my .NET localization or suggest how to localize usercontrol with umbraco?

  • Rik Helsen 670 posts 873 karma points
    Aug 05, 2010 @ 13:49
    Rik Helsen
    0

    Read up on this blogpost: http://www.nibble.be/?p=14

     

     

  • Vincent 75 posts 98 karma points
    Sep 10, 2010 @ 21:12
    Vincent
    0

    Hi,

    I'm looking to do the same here, but I have one other question, how can you find what is the current language of the Umbraco application?

    Thanks!

  • WG 2 posts 23 karma points
    Sep 10, 2010 @ 22:42
    WG
    0

    Try to get 'lang' parameter from session as you can see on code snippet above: Session["lang"]

  • fedar 10 posts 30 karma points
    Dec 19, 2011 @ 18:17
    fedar
    0

    I have the same problem
    I'm using user controls. net within umbraco macros
    in the development environment works fine with my language (Spanish), butproduction appears in English.
    I tried setting the culture in web.config in this way
    <system.web>
    <globalization uiCulture="es-uy"/>

    but still all the same

    some idea?

  • fedar 10 posts 30 karma points
    Dec 19, 2011 @ 18:19
    fedar
    0
  • Tom Fulton 2030 posts 4996 karma points c-trib
    Dec 19, 2011 @ 19:33
    Tom Fulton
    0

    Hi fedar,

    Have you adjusted the Hostnames for your site once moved to the production server?  The culture is set via Hostnames option on a node, and maybe you have it set to something.local, then when going to production @ something.com it's not finding any entries and reverting to english.

    Try to right-click your main node and click Manage Hostnames to make sure.

    -Tom

  • fedar 10 posts 30 karma points
    Dec 19, 2011 @ 19:42
    fedar
    0

    Hi Tom

    I configure the hostname,

    I set the hostname to the dictionary  but still appear inEnglish

    I use asp.net controls, specifically the gridview control

  • fedar 10 posts 30 karma points
    Dec 19, 2011 @ 19:45
    fedar
    0
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies