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 162 posts 639 karma points
    Nov 06, 2019 @ 22:27
    Jesse Andrews
    0

    A question on how to create a custom translation provider

    I am trying to build my own version of the passthrough provider due to the error I get when I try to use the existing one (see here for details). I've gotten it to show up as an option, but I'm having trouble getting the status to update during the Check operation. I believe I can set the status with the TranslationJobService, but I'm not sure how to inject that service into the provider. How should this be done?

  • Kevin Jump 1896 posts 11907 karma points MVP 4x c-trib
    Nov 06, 2019 @ 22:42
    Kevin Jump
    0

    Hi

    Hopefully, I've answered the question on the other post,

    but for completeness:

    You should be able to include TranstionJobService to the constructor of your connector and it will be injected by Umbraco's light inject implementation.

    but in a provider, you don't need to set the status via the service (in fact you probably shouldn't). you set the job status

    and return the job object in the attempt - Translation Manager then actually does a complete check of the items in a job to calculate the real status of the job (it checks to see if all values are marked as translated).

    so setting the job status in the job, doesn't actually mean it will stay as what you set it if Translation Manager doesn't think it should be.

    (i appreciate this is hard because the code is closed, i am writing up a bit more documentation on connectors, that will hopefully help with this stuff)

  • Kevin Jump 1896 posts 11907 karma points MVP 4x c-trib
    Nov 06, 2019 @ 22:45
    Kevin Jump
    0

    as an example :

    this is the v8 passthrough connectors check function:

     foreach(var node in job.Nodes)
     {
         foreach (var tab in node.Groups)
         {
            foreach(var property in tab.Properties)
            {
                property.Target = property.Source;
                MarkAsTranslated(property.Target);
            }
         }
     }
    
     job.Status = JobStatus.Received;
     return Task.FromResult(Attempt<TranslationJob>.Succeed(job));
    

    *MarkAsTranslated is a function that recurses in to the Target value and sets the the Translated value on all inner items.

  • Jesse Andrews 162 posts 639 karma points
    Nov 06, 2019 @ 22:48
    Jesse Andrews
    0

    Thanks for that code snippet. That clears up my confusion.

Please Sign in or register to post replies

Write your reply to:

Draft