Copied to clipboard

Flag this post as spam?

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


  • Manish 373 posts 929 karma points
    May 30, 2016 @ 09:41
    Manish
    0

    How to get language for a particular domain

    Hi

    I wanted to get the language selected for a particular url by user. For example I have set 4 urls for a page

    1. If abc.com is open it should have en-GB.
    2. if xyz.net is open it should have de-DE.

    enter image description here

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    May 30, 2016 @ 13:08
    Alex Skrypnyk
    0

    Hi Manish,

    It's prety easy issue with DomainService.

    var domain = ApplicationContext.Services.DomainService.GetByName("xyz.net");
    
    var culture = domain.LanguageIsoCode;
    

    Cheers,

    Alex

  • Manish 373 posts 929 karma points
    May 31, 2016 @ 06:37
    Manish
    0

    Thanks Alex

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    May 31, 2016 @ 09:38
    Alex Skrypnyk
    0

    You are welcome !

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    May 31, 2016 @ 10:06
    Dave Woestenborghs
    0

    I think you can also do this on your IPublishedContent object

    @content.GetCulture()
    

    Dave

  • Manish 373 posts 929 karma points
    May 31, 2016 @ 10:09
    Manish
    0

    Thanks Dave

    var culture = Domain.GetDomainsById(NodeId)[0].Language.CultureAlias;
    

    How i approach this

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    May 31, 2016 @ 10:11
    Dave Woestenborghs
    1

    I think the difference is that your approach uses a call to the database to find the culture. The other one is stored on the current request so no database calls which is better for performance.

    Dave

  • Manish 373 posts 929 karma points
    May 31, 2016 @ 10:14
    Manish
    0

    Well my scenario was bit different i wanted to get culture for all nodes so i looped through the code above.

    and if you need culture for current page you can also use this one

    var culture = Culture;
    

    Manish

  • 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