Skip to content

Commit

Permalink
Add language detection support
Browse files Browse the repository at this point in the history
  • Loading branch information
davc0n committed Aug 23, 2022
1 parent ec4bf31 commit 0cd2209
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Model/DetectedLanguage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Newtonsoft.Json;

namespace ModernMT.Model
{
public class DetectedLanguage : Model
{
[JsonProperty("billedCharacters")]
public int BilledCharacters { get; set; }

[JsonProperty("detectedLanguage")]
public string Language { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/ModernMTService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public List<string> ListSupportedLanguages()
return _client.Send<List<string>>("get", "/translate/languages");
}

public DetectedLanguage DetectLanguage(string q, string format = null)
{
var data = new Dictionary<string, dynamic>
{
{"q", q},
{"format", format}
};

return _client.Send<DetectedLanguage>("get", "/translate/detect", data);
}

public Translation Translate(string source, string target, string q, long[] hints = null,
string contextVector = null, TranslateOptions options = null)
{
Expand Down

0 comments on commit 0cd2209

Please sign in to comment.