Copied to clipboard

Flag this post as spam?

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

  • Audun Igesund 2 posts 72 karma points
    Mar 28, 2019 @ 11:44
    Audun Igesund

    Umbraco Language variant

    Is there a way to check if a Language variant exist? I have a site With two Languages, and want to link to a a variant of a page if it exist.

  • Audun Igesund 2 posts 72 karma points
    Mar 28, 2019 @ 14:24
    Audun Igesund

    I think i found a solution (probably not the best)

    var mylanguage = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();

    Here I can check if I am at the sami language-version and make a link to the Norwegian language-version.

    @if (mylanguage == "se-NO" && Model.HasValue("tittel", "nb")){
    <a href="@Model.GetUrl("nb")">here is a link to norwegian nb language</a>} 
  • Corné Strijkert 80 posts 456 karma points c-trib
    Apr 04, 2019 @ 19:30
    Corné Strijkert

    I think maybe a better way to do this is by checking the Cultures property on a IPublishedContent object.

    @if (Model.Cultures.ContainsKey("nb")) { //... }}

    Because properties have its own 'Allow varying by culture' setting, this can lead to unexpected results. It can happen that the property is not present for the given culture in contrast to parent object.

  • Markus Johansson 1926 posts 5833 karma points MVP 2x c-trib
    Apr 07, 2023 @ 13:27
    Markus Johansson

    These days (Umbraco 11 at least) you can go:



Please Sign in or register to post replies

Write your reply to: