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 932 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 6132 posts 23951 karma points MVP 7x 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 932 karma points
    May 31, 2016 @ 06:37
    Manish
    0

    Thanks Alex

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 31, 2016 @ 09:38
    Alex Skrypnyk
    0

    You are welcome !

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x 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 932 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 3504 posts 12133 karma points MVP 8x 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 932 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

Please Sign in or register to post replies

Write your reply to:

Draft