Copied to clipboard

Flag this post as spam?

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


  • Jesse Andrews 78 posts 295 karma points
    Jan 30, 2019 @ 02:44
    Jesse Andrews
    0

    Is there a way to get the translated versions of a page from the original page?

    I'm looking into creating a tool to automatically convert all internal links to link to the translated versions of those links for their respective languages. Is there currently a way to find the translated version of the page from the original page? If not, it would be a nice feature enhancement, perhaps running it through umbraco's relationship api.

  • Kevin Jump 1349 posts 8447 karma points MVP 2x c-trib
    Jan 30, 2019 @ 07:56
    Kevin Jump
    100

    Hi Jesse,

    Translation Manager is using the relations service underneath to manage how it translates between your original page and the translated one(s) -

    The LinkedPages package lets you see and edit these links from the page. (https://our.umbraco.com/packages/backoffice-extensions/linked-pages/) but its more of a management tool to help when that hasn't gone as expected.

    So you can update links by looking at the relationships of a link to find the other languages.

    There is a built-in link updater with Translation manager (since v2) updates the internal links in a translated item to those on the translated site as part of the approval process - I am not sure if this is the type of thing you are looking at?

    At the moment that link updater is tied into the translation jobs - but we do have a task on our list to have an option just to call it and it updates all links on the page.

    it's a bit complicated because links in pickers and standard RTE boxes are relatively simple, it just becomes a bit more of a pain when the link is inside some inner content which a grid inside using a leblender. so the link updater has "mappers" (much like translation manager does for content) which find the links and then do the updates.

    What you can access with the current version of translation manager is the LinkResolver (in Jumoo.TranslationManager.LinkUpdater namespace)

    if you know the translation set you can call it to resolve a link from one site to another.

    An example of that might look like:

                // get the translation manager services.
            var setService = TranslationManagerContext.Current.SetService;
            var resolver = new LinkResolver(contentService, relationService, setService);
    
            // work out what translation set a bit of content is in (so you know where the master site is)
            var sets = TranslationManagerContext.Current.SetService.GetTranslationSetByTargetPath(contentItem.Path);
    
            // a node can be in multiple sets, so you might have to do something here
            var set = sets.FirstOrDefault();
    
            // the site is the target language for the page based on the set it is in 
            var site = setService.GetTargetSite(set, contentItem.Path);
    
            // this will resolve it to the equivlant in the target set/site
            resolver.ResolveLink(set, site.Id, linkId);
    
            // this will resolve Udis in the target set/site.
            resolver.ResolveLink(set, site.Id, linkUdi);
    

    So you could do this, or you can just go through the relation service for each bit of content and resolve back to the parent (this is what we are doing, just with a few extra checks, for multiple sets, targets etc)

  • Jesse Andrews 78 posts 295 karma points
    Feb 01, 2019 @ 03:43
    Jesse Andrews
    0

    Thanks for the quick response. That sounds like exactly what I'm looking for.

  • Jesse Andrews 78 posts 295 karma points
    Feb 13, 2019 @ 03:18
    Jesse Andrews
    0

    Hi Kevin,

    I tried running a test page with an internal link in an rte through translation, but it didn't map the link to it's the equivalent link in the target language after I approved the changes. I checked Translations.config and both picker and inline options for links are set to true. The xliff 1.2 file I ran through the translation can be seen below.

    <?xml version="1.0" encoding="utf-8"?>
    <xliff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
      <file original="58" source-language="en-US" datatype="html" target-language="es" date="2019-02-12T18:48:28Z">
        <body>
          <group resname="Test Link Mapper" id="2482_1">
            <group resname="content" id="content_2">
              <group resname="bodyText" id="3694">
                <group resname="" id="6eec7175-1be3-372e-46c9-504390b6337b_3">
                  <group resname="Umbraco.Grid.LeBlender" id="Umbraco.Grid.LeBlender_1_4">
                    <group resname="Umbraco.Grid.LeBlender" id="1_5">
                      <group resname="Umbraco.NestedContent" id="editions_7">
                        <group resname="edition" id="edition_1_8">
                          <group resname="FlexibleLinkV2" id="2_10">
                            <trans-unit resname="FlexibleLinkV2" extradata="" id="0_11">
                              <source><![CDATA[Software]]></source>
                              <target><![CDATA[Spanish Test]]></target>
                            </trans-unit>
                          </group>
                          <trans-unit resname="Umbraco.Textbox" extradata="" id="1_9">
                            <source><![CDATA[Test]]></source>
                            <target><![CDATA[Spanish Test]]></target>
                          </trans-unit>
                          <trans-unit resname="Umbraco.TextboxMultiple" extradata="" id="6_12">
                            <source><![CDATA[Test]]></source>
                            <target><![CDATA[Spanish Test]]></target>
                          </trans-unit>
                        </group>
                      </group>
                      <trans-unit resname="Umbraco.Textbox" extradata="" id="titleLeadIn_6">
                        <source><![CDATA[Test]]></source>
                        <target><![CDATA[Spanish Test]]></target>
                      </trans-unit>
                    </group>
                  </group>
                  <trans-unit resname="Umbraco.Grid.rte" extradata="Html" id="Umbraco.Grid.rte_1_13">
                    <source><![CDATA[<p><a data-udi="umb://document/a7cff451ae7944e593c38309c8b14cb3" href="/{localLink:umb://document/a7cff451ae7944e593c38309c8b14cb3}" title="Software">Test link</a></p>]]></source>
                    <target><![CDATA[<p><a data-udi="umb://document/a7cff451ae7944e593c38309c8b14cb3" href="/{localLink:umb://document/a7cff451ae7944e593c38309c8b14cb3}" title="Software">Spanish Test link</a></p>]]></target>
                  </trans-unit>
                </group>
              </group>
            </group>
          </group>
        </body>
      </file>
    </xliff>
    

    I just manually filled in the targets by copying the source. At the bottom there is a grid rte control with a link to one of the pages on the master site. This link wasn't automatically pointed at the Spanish version of the page. Is there something I'm missing? I'm running v2.1.5 of Translation Manager (haven't installed the updated version of the xliff provider you made in response to one of our other threads, since it turned out the translation service we wanted it for didn't support xliff at all).

  • Kevin Jump 1349 posts 8447 karma points MVP 2x c-trib
    Feb 13, 2019 @ 09:19
    Kevin Jump
    0

    Hi Jess

    The link updating happens at the approve & publish (or just approve and save) phase, so any link information that ends up inside a link inside the XLIFF won't update.

    When you approve and save and then view the translated content on the site you should see the links all now point to the language site.

    all links should be updated not just the ones that are then in the XLIFF file (we don't, for example, put content pickers into the XLIFF, but the links are updated)

    but only links that have an equivalent in the language site will be updated - so there has to be a relationship between the page being linked to and the page on the target site (these should already be in place if you are translating the site / created it with copy relate to original).

    but if it doesn't seem to be working, try turning up the logging (in log4net.config)

      <logger name="Jumoo.TranslationManager">
        <level value="DEBUG" />
      </logger>
    

    you will then see lots of debugging, but on approval, you should also see entries for LinkUpdater - and it should already be logging things if it encounters errors.

    Kevin

  • Jesse Andrews 78 posts 295 karma points
    Feb 14, 2019 @ 02:48
    Jesse Andrews
    0

    I tested it with the debugger on, but didn't encounter any errors. It appears to be attempting to map it, as there is a line showing the before and after, but the link doesn't change. See below for the relevant lines from a translating a page with just one link within a grid rte. 2019-02-13 18:24:56,518 [P14572/D8/T21] DEBUG

    Jumoo.TranslationManager.LinkUpdater.LinkUpdater - Checking: bodyText Umbraco.Grid
    2019-02-13 18:24:56,528 [P14572/D8/T21] DEBUG Jumoo.TranslationManager.LinkUpdater.LinkUpdater - Setting : [bodyText] (Source:{
      "name": "1 column layout",
      "sections": [
        {
          "grid": 12,
          "rows": [
            {
              "label": "1 Column",
              "name": "1 Column",
              "areas": [
                {
                  "grid": 12,
                  "hasConfig": false,
                  "controls": [
                    {
                      "value": "<p><a data-udi=\"umb://document/f008e9e9ee8f467dbe719231850f26cb\" href=\"/{localLink:umb://document/f008e9e9ee8f467dbe719231850f26cb}\" title=\"Test Link Mapper\">Test link</a></p>",
                      "editor": {
                        "alias": "rte"
                      },
                      "active": true
                    }
                  ],
                  "active": true,
                  "hasActiveChild": true
                }
              ],
              "hasConfig": false,
              "id": "86764c55-1d75-59ba-4a84-a934fefb2b62",
              "hasActiveChild": true,
              "active": true
            }
          ]
        }
      ]
    }) [{
      "name": "1 column layout",
      "sections": [
        {
          "grid": "12",
          "rows": [
            {
              "label": "1 Column",
              "name": "1 Column",
              "hasConfig": false,
              "id": "86764c55-1d75-59ba-4a84-a934fefb2b62",
              "areas": [
                {
                  "grid": "12",
                  "hasConfig": false,
                  "controls": [
                    {
                      "value": "<p><a data-udi=\"umb://document/f008e9e9ee8f467dbe719231850f26cb\" href=\"/{localLink:umb://document/f008e9e9ee8f467dbe719231850f26cb}\" title=\"Test Link Mapper\">Spanish Test link</a></p>",
                      "editor": {
                        "alias": "rte"
                      },
                      "active": true
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    } > {
      "name": "1 column layout",
      "sections": [
        {
          "grid": "12",
          "rows": [
            {
              "label": "1 Column",
              "name": "1 Column",
              "hasConfig": false,
              "id": "86764c55-1d75-59ba-4a84-a934fefb2b62",
              "areas": [
                {
                  "grid": "12",
                  "hasConfig": false,
                  "controls": [
                    {
                      "value": "<p><a data-udi=\"umb://document/f008e9e9ee8f467dbe719231850f26cb\" href=\"/{localLink:umb://document/f008e9e9ee8f467dbe719231850f26cb}\" title=\"Test Link Mapper\">Spanish Test link</a></p>",
                      "editor": {
                        "alias": "rte"
                      },
                      "active": true
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }]
    

    I know the node I linked to in this test has a spanish relation, so I'm at a bit of a loss why it's not transformed. Any chance a missing license prevent it from running properly when testing in a local environment? I haven't installed one yet, though I imagine there would be errors logged if it was looking for that.

Please Sign in or register to post replies

Write your reply to:

Draft