Copied to clipboard

Flag this post as spam?

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


  • Stephen Myers 4 posts 104 karma points
    Mar 24, 2020 @ 10:28
    Stephen Myers
    0

    xliff 1.2 issue

    Hi,

    After upgrading to version 2.4.6 to fix nested content mapping issues, the xliff provider fails when the format is set to xliff 1.2.

    When uploaded a translated file, the UI returns an error with the message "Cannot Load: cannot find xliff file" The process works fine when set to Xliff 2, however our clients translation provider requires files in xliff 1.2 format.

    After browsing the decompiled source code, there appears to be a bug in SimpleFile.XliffProvider, in the method LoadJobFromFile:

    public TranslationAttempt<TranslationJob> LoadJobFromFile(string filepath, TranslationJob job, bool blankTarget)
    {
        SimpleFileIO simpleFileIo = new SimpleFileIO(this.folder);
        this.logger.Debug<XliffProvider>("File Location: {0}", (Func<object>) (() => (object) filepath));
        SimpleProviderOptions properties = this.GetProperties(job.ProviderProperties);
        properties.uploadedFile = filepath;
        try
        {
            if (properties.format.InvariantEquals("xliff2"))
            {
                using (Stream fileStream = simpleFileIo.ReadFile(filepath)) 
                {
                    TranslationAttempt<TranslationJob> translationAttempt = new Xliff20Serializer().Deserialize(new Xliff20IOHelper().ReadFromStream(fileStream), job, blankTarget, true); 
                    if (translationAttempt.Success)
                    {
                        translationAttempt.Result.ProviderProperties = JsonConvert.SerializeObject((object) properties);
                        return TranslationAttempt<TranslationJob>.Succeed(translationAttempt.Result);
                    }
                }
            }
            else
            {
                Xliff12IOHelper xliff12IoHelper = new Xliff12IOHelper();
                using (simpleFileIo.ReadFile(filepath)) 
                {
                    TranslationAttempt<TranslationJob> translationAttempt = new Xliff12Serializer(this.logger).Deserialize(xliff12IoHelper.LoadFromFile(filepath), job, false, true); 
                    if (!(bool) translationAttempt)
                        return TranslationAttempt<TranslationJob>.Fail(translationAttempt.Message);
                    translationAttempt.Result.ProviderProperties = JsonConvert.SerializeObject((object) properties);
                    return TranslationAttempt<TranslationJob>.Succeed(translationAttempt.Result);
                }
            }
        }
        catch (Exception ex)
        {
            return TranslationAttempt<TranslationJob>.Fail("Cannot Load : " + ex.Message);
        }
        return TranslationAttempt<TranslationJob>.Fail("Unable to Load File for Job");
    }
    

    The code that runs when the file is in xliff 1.2 format seems to incorrectly load the file from a path instead of a stream, as is the case for loading xliff 2 files.

    Any help would be appreciated, Thanks!

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Mar 24, 2020 @ 11:41
    Kevin Jump
    100

    Hi Stephen,

    Yes good spot, not sure why it does that, but it's fixed now:

    You should only need to upgrade the Xliff package:

    Install-Package Jumoo.TranslationManager.Providers.Xliff -Version 2.3.6
    

    (https://www.nuget.org/packages/Jumoo.TranslationManager.Providers.Xliff/2.3.7)

  • Stephen Myers 4 posts 104 karma points
    Mar 24, 2020 @ 12:40
    Stephen Myers
    0

    Great, thanks for the speedy response Kevin

Please Sign in or register to post replies

Write your reply to:

Draft