Unofficial Reverso Context client for .NET.
using ReversoApi; using ReversoApi.Models; using ReversoApi.Models.Requests; using var client = new ReversoClient(); var result = await client.TranslateAsync(new TranslateRequest { Word = "influence", Sentence = "They all wanted to influence the decision.", From = Language.En, To = Language.Ru });
This method automatically chooses which Reverso API to call:
- If input is 1 word: uses word translation API.
- If input is a short segment (2-3 words): uses segment translation API.
- If input is more than 3 words: uses text translation API.
Input selection:
- If
Wordis provided, decision is based onWord. - If
Wordis empty, decision is based onSentence. - In word mode,
Sentenceis used as context.
Response shape depends on translation type:
- Word/segment translations return data in
Sources. - Text translations return data in
Translation.
Experimental feature.
This method uses another Reverso API variant and is usually better for words and short segments.
Requirements:
Wordis requiredSentenceis requiredWordPosdefaults to"0"
Example:
using var client = new ReversoClient(); var segment = await client.TranslateSegmentAsync(new TranslateRequest { Word = "translation", Sentence = "Enjoy cutting-edge AI-powered translation from Reverso in 25+ languages", WordPos = "30", From = Language.En, To = Language.Ru });
TranslateRequest:
Word(optional)Sentence(optional)WordPos(optional, default"0")From(required)To(required)
Validation:
- at least one of
WordorSentencemust be provided WordPoscannot be empty
TranslateResponse:
Kind(Word,Segment,Sentence)InputTranslation(text mode)Sources(word/segment modes)DirectionFrom,DirectionTo,IsDirectionChanged(text mode)Success,Error,Message
Run all tests:
dotnet testCurrent tests include:
- unit tests for request validation and direction formatting
- integration tests for:
TranslateAsyncword modeTranslateAsyncsegment modeTranslateAsyncsentence/text modeTranslateSegmentAsync
This code is completely free to use. Its operation is provided as-is and is not guaranteed.