Copied to clipboard

Flag this post as spam?

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


  • Patrick de Mooij 4 posts 84 karma points c-trib
    Jun 12, 2019 @ 07:12
    Patrick de Mooij
    0

    CultureInfo in PublishedCultureInfo

    Currently in Umbraco, you are able to use GetCultures() on a page to get all the cultures. You'll get a dictionary of

    If I were to create a multilanguage page, I would want to put links to the alternate pages in the head of the page. For this, I need the TwoLetterIsoLanguageName. Currently this is how I do it:

    @if (Model.Cultures.Count > 1)
    {
        foreach (string culture in Model.Cultures.Keys)
        {
    <link rel="alternate" href="@Model.GetUrl(culture)" hreflang="@(culture.Substring(0, 2))" />
        }
    }
    

    I think that the property "Culture" on PublishedCultureInfo should be replaced to a CultureInfo object. We can easily use CultureInfo.GetCultureInfo(name) to load it in. I think it makes it easier for the user to use cultures.

    I wanted to post it on the forums first to check for any feedback on the idea as it's also possible for the user to use CultureInfo.GetCultureInfo instead.

Please Sign in or register to post replies

Write your reply to:

Draft