Copied to clipboard

Flag this post as spam?

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


  • Petr Snobelt 923 posts 1535 karma points
    Jul 25, 2011 @ 09:06
    Petr Snobelt
    0

    Base and dictionary

    Hi, when I try use getDictionaryItem from umbraco.library in base method I found out it do not respect language setings from manage domain dialog.

    I try check CurrentUICulture and it is not changed based on domain :-(

    Is there any way how to set CurrentUICulture based on domain, which is necessery to getDictionaryItem works correctly?

     

    Thanks

    Petr

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 25, 2011 @ 09:46
    Stefan Kip
    1

    You could do it yourself, looks like it's not built in to umbraco:

    string domain = HttpContext.Current.Request.Url.Host; // Not sure about this, might have to tweak
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(umbraco.cms.businesslogic.web.Domain.GetDomain(domain).Language.CultureAlias);
  • Petr Snobelt 923 posts 1535 karma points
    Jul 29, 2011 @ 21:25
    Petr Snobelt
    0

    That's exactly what I need (except CurrentUICulture instead of CurrentCulture :-).

    Thank you very much.

    I end with this code:

        private static void TrySetCulture()
        {
            string domain = HttpContext.Current.Request.Url.Host; //Host only
            if (TrySetCulture(domain)) return;
    
            domain = HttpContext.Current.Request.Url.Authority; //Host with port
            if (TrySetCulture(domain)) return;
        }
    
        private static bool TrySetCulture(string domain) {
            var uDomain = umbraco.cms.businesslogic.web.Domain.GetDomain(domain);
            if (uDomain == null) return false;
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(uDomain.Language.CultureAlias);
            return true;
        }
    

    Petr

Please Sign in or register to post replies

Write your reply to:

Draft