public void ETSApi_FetchTranslationNoTags_ValidTranslation() { var xliffDocument = new Xliff(engFraLP.SourceCulture, engFraLP.TargetCulture); xliffDocument.AddSourceText(StringResource.BasicText); var translatedXliffText = ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engFraLP, xliffDocument); var translatedXliff = Sdl.Community.Toolkit.LanguagePlatform.XliffConverter.Converter.ParseXliffString(translatedXliffText); Assert.IsTrue(translatedXliff.GetTargetSegments().Any()); Assert.AreEqual( StringResource.BasicTranslation, translatedXliff.GetTargetSegments()[0].ToString()); var token = ETSTranslatorHelper.GetAuthToken(basicAuthTranslationOptions, userCredentials); basicAuthTranslationOptions.ApiToken = token; translatedXliffText = ETSTranslatorHelper.GetTranslation(basicAuthTranslationOptions, engFraLP, xliffDocument); translatedXliff = Sdl.Community.Toolkit.LanguagePlatform.XliffConverter.Converter.ParseXliffString(translatedXliffText); Assert.IsTrue(translatedXliff.GetTargetSegments().Any()); Assert.AreEqual( StringResource.BasicTranslation, translatedXliff.GetTargetSegments()[0].ToString()); }
public void ETSApi_FetchTranslation_InvalidTranslation() { XliffConverter.xliff xliffDocument = new XliffConverter.xliff(engFraLP.SourceCulture, engFraLP.TargetCulture); xliffDocument.AddSourceText(StringResource.BasicText); ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engInvLP, xliffDocument); }
public void ETSApi_FetchTranslationEmoji_ValidTranslation() { var xliffDocument = new Xliff(engFraLP.SourceCulture, engFraLP.TargetCulture, encodeUtf16: true); xliffDocument.AddSourceText(StringResource.BasicEmojiTest); var translatedXliffText = ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engFraLP, xliffDocument); var translatedXliff = Sdl.Community.Toolkit.LanguagePlatform.XliffConverter.Converter.ParseXliffString(translatedXliffText); Assert.IsTrue(translatedXliff.GetTargetSegments().Any()); Assert.AreEqual(StringResource.BasicEmojiTranslation, translatedXliff.GetTargetSegments()[0].ToString()); }
public void ETSApi_FetchTranslationEmoji_ValidTranslation() { XliffConverter.xliff xliffDocument = new XliffConverter.xliff(engFraLP.SourceCulture, engFraLP.TargetCulture, encodeUTF16: true); xliffDocument.AddSourceText(StringResource.BasicEmojiTest); string translatedXliffText = ETSTranslatorHelper.GetTranslation(apiKeyTranslationOptions, engFraLP, xliffDocument); XliffConverter.xliff translatedXliff = XliffConverter.Converter.ParseXliffString(translatedXliffText); Assert.IsTrue(translatedXliff.GetTargetSegments().Any()); Assert.AreEqual( StringResource.BasicEmojiTranslation, translatedXliff.GetTargetSegments()[0].ToString()); }
/// <summary> /// Creates a translated segment by calling upon the ETS API (via helper methods) /// </summary> /// <param name="sourceSegment"></param> /// <returns></returns> private Segment[] TranslateSegments(Segment[] sourceSegments) { var xliffDocument = CreateXliffFile(sourceSegments); var translatedXliffText = ETSTranslatorHelper.GetTranslation( provider.Options, languageDirection, xliffDocument); var translatedXliff = Converter.ParseXliffString(translatedXliffText); if (translatedXliff != null) { return(translatedXliff.GetTargetSegments()); } return(new Segment[sourceSegments.Length]); }
/// <summary> /// Creates a translated segment by calling upon the ETS API (via helper methods) /// </summary> /// <param name="sourceSegment"></param> /// <returns></returns> private Segment[] TranslateSegments(Segment[] sourceSegments) { Log.logger.Trace(""); try { XliffConverter.xliff xliffDocument = CreateXliffFile(sourceSegments); string translatedXliffText = ETSTranslatorHelper.GetTranslation( provider.Options, languageDirection, xliffDocument); XliffConverter.xliff translatedXliff = XliffConverter.Converter.ParseXliffString(translatedXliffText); return(translatedXliff.GetTargetSegments()); } catch (Exception e) { Log.logger.Error(e, "Error in TranslateSegments"); return(new Segment[sourceSegments.Length]); } }