public void TranslationTranslateResultGetTest() { TranslationFileResponse fileResponse = new TranslationFileResponse(); fileResponse = translationApi.TranslationTranslateFileGet("../../test.txt", "en", "fr", null, null, false, false, null, null, null, null, true, null, null); String translationResponse = null; translationResponse = translationApi.TranslationTranslateResultGet(fileResponse.RequestId, null); Assert.IsNotNull(translationResponse); }
public void TranslationTranslateStatusGetTest() { TranslationFileResponse fileResponse = new TranslationFileResponse(); fileResponse = translationApi.TranslationTranslateFileGet("../../test.txt", "en", "fr", null, null, false, false, null, null, null, null, true, null, null); TranslationStatus translationStatus = new TranslationStatus(); translationStatus = translationApi.TranslationTranslateStatusGet(fileResponse.RequestId, null); Assert.IsNotNull(translationStatus.Status); }
public void TranslationTranslateResultGetAsyncTest() { TranslationFileResponse fileResponse = new TranslationFileResponse(); fileResponse = translationApi.TranslationTranslateFileGet("../../test.txt", "en", "fr", null, null, false, false, null, null, null, null, true, null, null); String translationResponse = null ; Task.Run(async () => { translationResponse = await translationApi.TranslationTranslateResultGetAsync(fileResponse.RequestId, null); }).Wait(); Assert.IsNotNull(translationResponse); }
public void TranslationTranslateFileGetTest() { TranslationFileResponse fileResponse = new TranslationFileResponse(); fileResponse = translationApi.TranslationTranslateFileGet("../../test.txt", "en", "fr", null, null, false, false, null, null, null, null, false, null, null); Assert.IsNotNull(fileResponse); }
public void TranslationTranslateFileGetAsyncTest() { TranslationFileResponse fileResponse = new TranslationFileResponse(); Task.Run(async () => { fileResponse = await translationApi.TranslationTranslateFileGetAsync("../../test.txt", "en", "fr", null, null, true, false, null, null, null, null, false, null, null); }).Wait(); Assert.IsNotNull(fileResponse); }
public void TranslationTranslateCancelGetTest() { TranslationFileResponse fileResponse = new TranslationFileResponse(); fileResponse = translationApi.TranslationTranslateFileGet("../../test.txt", "en", "fr", null, null, false, false, null, null, null, null, true, null, null); TranslationCancel translationCancel = new TranslationCancel(); translationCancel = translationApi.TranslationTranslateCancelGet(fileResponse.RequestId, null); Assert.IsNotNull(translationCancel.ToString()); }
/// <summary> /// Translate File Translate a file from source language to target language\n\n\n* In asynchronous mode (async=true), the response will be a JSON containing a request identifier. This identifier can then be used to poll the request status and its result when completed.\n\n ```\n {\n \"requestId\": \"54a3d860e62ea467b136eddb\" /* Request identifier to use to get the status,\n the result of the request and to cancel it */\n \"error\": \"\", /* Error at request level */\n }\n ```\n\n* In synchronous mode, the response will be either:\n\n * The **translated document**, directly, if `source` parameters was not `auto` and `withSource` was not true\n * A `multipart/mixed` document with the following parts:\n\n 1. **Detected language**, if request was done with `auto` source language\n\n * Header:\n\n `part-name: detectedLanguage`\n\n * Body: JSON document\n ```\n {\n detectedLanguage: \"string\"\n detectedLanguageConfidence : number\n }\n ```\n\n 2. **Source document**, if request was done with `withSource`:\n\n * Header: `part-name: source`\n * Body: Source document\n\n 3. **Translated document**\n\n * Header: `part-name: output`\n\n * Body: Translated document\n /// </summary> /// <param name="Input">Input file\n</param>/// <param name="Source">Source language code ([details](#description_langage_code_values)) or `auto`.\n\nWhen the value is set to `auto`, the language will be automatically detected, used to enhance the translation, and returned in output.\n</param>/// <param name="Target">Target language code ([details](#description_langage_code_values))</param>/// <param name="Format">Format of the source text.\n\nValid values are `text` for plain text, `html` for HTML pages, and `auto` for automatic detection. The MIME type of file format supported by SYSTRAN can also be used (application/vnd.openxmlformats, application/vnd.oasis.opendocument, ...)\n</param>/// <param name="Profile">Profile id\n</param>/// <param name="WithSource">If `true`, the source will also be sent back in the response message. It can be useful when used with the withAnnotations option to align the source document with the translated document\n</param>/// <param name="WithAnnotations">If `true`, different annotations will be provided in the translated document. If the option 'withSource' is used, the annotations will also be provided in the source document. It will provide segments, tokens, not found words,...\n</param>/// <param name="WithDictionary">User Dictionary or/and Normalization Dictionary ids to be applied to the translation result. Each dictionary 'id' has to be separate by a comma.\n</param>/// <param name="WithCorpus">Corpus to be applied to the translation result. Each corpus 'id' has to be separate by a comma.\n</param>/// <param name="Options">Additional options.\n\nAn option can be a JSON object containing a set of key/value generic options supported by the translator. It can also be a string with the syntax '<key>:<value>' to pass a key/value generic option to the translator.\n</param>/// <param name="Encoding">Encoding. `base64` can be useful to send binary documents in the JSON body. Please note that another alternative is to use translateFile\n</param>/// <param name="Async">If `true`, the translation is performed asynchronously.\n\nThe \"/translate/status\" service must be used to wait for the completion of the request and the \"translate/result\" service must be used to get the final result. The \"/translate/cancel\" can be used to cancel the request.\n</param>/// <param name="BatchId">Batch Identifier\n</param>/// <param name="Callback">Javascript callback function name for JSONP Support\n</param> /// <returns>TranslationFileResponse</returns> public TranslationFileResponse TranslationTranslateFileGet (string Input, string Source, string Target, string Format, int? Profile, bool? WithSource, bool? WithAnnotations, string WithDictionary, string WithCorpus, List<string> Options, string Encoding, bool? Async, string BatchId, string Callback) { // verify the required parameter 'Input' is set if (Input == null) throw new ApiException(400, "Missing required parameter 'Input' when calling TranslationTranslateFileGet"); // verify the required parameter 'Target' is set if (Target == null) throw new ApiException(400, "Missing required parameter 'Target' when calling TranslationTranslateFileGet"); var path = "/translation/file/translate"; path = path.Replace("{format}", "json"); var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>(); var fileParams = new Dictionary<String, String>(); String postBody = null; if (Source != null) queryParams.Add("source", apiClient.ParameterToString(Source)); // query parameter if (Target != null) queryParams.Add("target", apiClient.ParameterToString(Target)); // query parameter if (Format != null) queryParams.Add("format", apiClient.ParameterToString(Format)); // query parameter if (Profile != null) queryParams.Add("profile", apiClient.ParameterToString(Profile)); // query parameter if (WithSource != null) queryParams.Add("withSource", apiClient.ParameterToString(WithSource)); // query parameter if (WithAnnotations != null) queryParams.Add("withAnnotations", apiClient.ParameterToString(WithAnnotations)); // query parameter if (WithDictionary != null) queryParams.Add("withDictionary", apiClient.ParameterToString(WithDictionary)); // query parameter if (WithCorpus != null) queryParams.Add("withCorpus", apiClient.ParameterToString(WithCorpus)); // query parameter if (Options != null) queryParams.Add("options", apiClient.ParameterToString(Options)); // query parameter if (Encoding != null) queryParams.Add("encoding", apiClient.ParameterToString(Encoding)); // query parameter if (Async != null) queryParams.Add("async", apiClient.ParameterToString(Async)); // query parameter if (BatchId != null) queryParams.Add("batchId", apiClient.ParameterToString(BatchId)); // query parameter if (Callback != null) queryParams.Add("callback", apiClient.ParameterToString(Callback)); // query parameter if (Input != null) fileParams.Add("input", Input); // authentication setting, if any String[] authSettings = new String[] { "accessToken", "apiKey" }; // make the HTTP request IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException ((int)response.StatusCode, "Error calling TranslationTranslateFileGet: " + response.Content, response.Content); } if (!(bool) Async){ //non async calls return raw text, not JSON, avoid deserialization TranslationFileResponse fileResponse = new TranslationFileResponse(); fileResponse.Outputs = new List<TranslationOutput>(); TranslationOutput output = new TranslationOutput(); output.Output = response.Content; fileResponse.Outputs.Add(output); return fileResponse; } else return (TranslationFileResponse) apiClient.Deserialize(response.Content, typeof(TranslationFileResponse)); }