Copied to clipboard

Flag this post as spam?

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


  • Jason 16 posts 166 karma points
    Jun 01, 2023 @ 05:42
    Jason
    0

    URLs on Multilingual Sites

    I am testing out Heartcore and struggling with a few things in relation to URLs and multilingual sites:

    1. I am trying to figure out if it's possible to have a different URL for each language variant of a page. I am currently seeing a message "This item is not published" under the Links section of the language variant of a page, even though the page is published under the alternate language. The name of the page, and therefore the URL, is going to be localised per language so the URL should be localised too. Is there a way to do that?

    2. How do you query a page by URL for an alternate language? Currently I am using the ContentDeliveryService.GetByUrl(path, culture) but when you use a non-default language, then it fails to find the published page, presumably because the URL is not there for the alternate language (see point 1 above). I have tried using the URL shown for the default language but that doesn't work for the alternate language.

    3. I have also noticed that for pages where there is only an alternate language version of the page (you don't want the page to be displayed on the default language version of the site), you don't get any URL for the page when it is published.

    Can someone please point me in the right direction for dealing with URLs on multilingual sites?

    Thanks,

    Jason

  • Lindow 154 posts 1301 karma points
    Jun 01, 2023 @ 07:38
    Lindow
    0

    Hi Jason

    1. Regarding "This item is not published" it sounds like a UI bug but the queries should still work :)

    2. I would recommend querying the data by content GUID, getting the "_url" property, and then only changing the Accept-Language header which I believe is the main thing you might be missing. Reference - https://docs.umbraco.com/umbraco-heartcore/api-documentation/content-delivery#access-via-an-accept-language-header

    What you asked about is still doable. See this example enter image description here

    3 It should work if you follow what I wrote in the 2nd section :)

  • Jason 16 posts 166 karma points
    Jun 01, 2023 @ 08:08
    Jason
    0

    Hi Lindow,

    1. Just to clarify my question here, I am looking to localise the URL of the page for each culture so the URL could be completely different for each language and contain translated keywords for each language, i.e. the URL for a page in culture en-US is going to be completely different to the URL for fr-FR.
    2. Maybe I wasn't clear in my original message. I am using the Umbraco.Heartcore.Client.Net client library which contains the ContentDeliveryService.Content.GetByUrl(url, culture) method. So, I assume that specifying the culture parameter includes the appropriate language header. But, this does not seem to work as I have localised versions of a page but when I specify a culture different from the default language, the query does not find the page even though it is published. As mentioned, there is no URL listed for the alternate language (it just shows "this item is not published"). I can't retrieve the page by GUID because I don't know the GUID...I only have a URL from the browser and don't want to include GUIDs in my URLs.
    3. As above, if you do not publish a version of a page in the default language and just publish a version for an alternate language then there is no URL associated with the page so I cannot retrieve it by URL. Even if I try and retrieve this page by ID, it does not seem to work, maybe because there is no content for the default language.

    Thanks,

    Jason

  • Lindow 154 posts 1301 karma points
    Jun 01, 2023 @ 08:44
    Lindow
    0

    Hi again.

    1. This is why I recommend fetching the content node by ID and grabbing the "_url" property instead and you won't be dependent on the ever changing URLs
    2. You can find the GUID by going to the backoffice>node you watch to fetch>info tab
    3. That's weird as it works for me, although I use Postman to fetch the data. It shouldn't make a difference, though.

    In general, it sounds like you might be blocked by the .NET SDK and its lack of methods.

    You can create an issue on the GH repo for it here https://github.com/umbraco/Umbraco.Headless.Client.Net/issues

  • Jason 16 posts 166 karma points
    Jun 01, 2023 @ 09:25
    Jason
    0

    Hi.

    1. How do you fetch by ID when you just have a URL from the browser, e.g. the user hits the page https://www.site.com/guides/sample-guide and I only have the URL to work with (i.e. no GUID)? Obviously, I can define a custom property to store a user-defined slug for a page and then localise that property value but then I need to make that enforce that as unique across all other pages and the user would have to enter a value which is clunky. Is it possible to enforce uniqueness within a language for an individual property and have it auto-populate somehow?
    2. I know how to find the GUID, but as per my above point, I need to fetch by URL. I was hoping to make use of the automatically assigned URL for a page in Heartcore, but maybe I have to use a custom property for the slug as mentioned above.
    3. I have just tested with Postman and it doesn't work. So, I have a page published in en-US and the URL shows as /home/guides/sample-guide. The same article is localised for en-AU but it shows "This item is not published in the Links section of the Info tab".

    When I hit https://cdn.umbraco.io/content/url?url=/home/guides/sample-guide with accept-language of en-US I get the article. When I hit the same URL with accept-language of en-AU I get a not found. Can you please outline how you are getting this to work?

    Thanks,

    Jason

  • Lindow 154 posts 1301 karma points
    Jun 01, 2023 @ 09:43
    Lindow
    0

    enter image description here

    I have 2 languages. English and Finnish.

    Already had the node for both languages in the backoffice but unpublished the English one for the demonstration.

    1st screenshot is with the node published in both languages. 2nd is with only the Finnish one published which is the secondary language.

    enter image description here

  • Jason 16 posts 166 karma points
    Jun 01, 2023 @ 10:51
    Jason
    100

    OK...I have figured this out now. It was all because the root page had not been created and published for en-AU. Once that was published then the URL started populating correctly down to those child pages for en-AU in all of the use cases that I had originally outlined.

    A simple user error on my part and the message "This item is not published" is accurate although it would be nice if the message was a bit more informative around why the item was not published - in this case it is because an ancestor had not been created & published for the selected language.

    Thanks for your help on this.

  • Lindow 154 posts 1301 karma points
    Jun 01, 2023 @ 13:20
    Lindow
    0

    Great to hear that you resolved it :)

    Please, mark this thread as solved when you find the time.

Please Sign in or register to post replies

Write your reply to:

Draft