client.Languages
Каждый метод этого пространства имён: его сигнатура, параметры, что он возвращает, и пример.
Методы
Every language a translated send or preview accepts. The package also ships a copy of the table as OpenEmail.Constants.Languages.All.
Languages.ListAsync
List every language a message can be sent in
Task<IReadOnlyList<JsonObject>> ListAsync( string? apiKey = null, CancellationToken cancellationToken = default)Returns the whole language table in one response, with no cursor. It sits behind a key like every other endpoint but needs no scope, because it names no data belonging to anybody. The table is around two hundred rows and changes a handful of times a year, so fetch it once and keep it.
The order is meaningful. The languages people are most likely to be emailed in come first, then regional variants, then the rest by region. A picker should render the rows in the order they arrive until somebody types, then search native, label and code together. Show native first, since it is the word someone looking for their own language is scanning for, and never show flag on its own: a flag names a country, not a language.
Any row's code, label or native is accepted by translate.to on Emails.SendAsync and by Emails.TranslateAsync. The package also ships the same table as OpenEmail.Constants.Languages.All, with OpenEmailClient.ResolveLanguage to find a row by any of those names, which is useful before the first request, while this call returns the server's current rows.
Параметры
apiKeystring?Authenticates this call with a different key.
cancellationTokenCancellationTokenCancels the request.
Возвращает
A list of JsonObject items, each with code (BCP-47), label (English name), native (endonym), flag and rtl.
Пример
var languages = await client.Languages.ListAsync(); foreach (var language in languages){ Console.WriteLine($"{language["native"]} ({language["code"]}){((bool?)language["rtl"] == true ? " right to left" : "")}");}Примечания
rtlmarks right-to-left targets. A translated body for one of them is wrapped indir="rtl"before it is sent.The bundled
Languages.Alltable can lag the server by however old your installed package is, so prefer this call when a newly added language matters.
Также доступно в
- API
GET /languages- TypeScript
languages.list()- Python
languages.list()- Ruby
languages.list- PHP
languages->list- Go
Languages.List- Java
languages().list- CLI
openemail languages list