Zur Dokumentation springen
Python

openemail.languages

Jede Methode in diesem Namespace: ihre Signatur, ihre Parameter, was sie zurückgibt und ein Beispiel.

Methoden

Every language a translated send or preview accepts.

languages.list()

List every language a message can be sent in

Kein Geltungsbereich
Signatur
def list(    *,    api_key: str | None = None,    timeout: float | None = None,) -> builtins.list[LanguageResource]

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 as 'to' in the translate dict of emails.send and in the body of emails.translate. The package also ships the same table as LANGUAGES, with resolve_language to look a code, an English name or an endonym up in it, which is useful before the first request, while this call returns the server's current rows.

Parameter

api_keystr

Authenticates this call with a different key.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Rückgabe

list[LanguageResource], each a dict with code (BCP-47), label (English name), native (endonym), flag and rtl.

Beispiel

from openemail import openemail languages = openemail.languages.list()by_code = {language['code']: language for language in languages} german = by_code.get('de')right_to_left = [language['native'] for language in languages if language['rtl']] print(german['native'] if german else 'German is not offered', len(right_to_left))

Hinweise

  • rtl marks right-to-left targets. A translated body for one of them is wrapped in dir="rtl" before it is sent.

  • The bundled LANGUAGES table can lag the server by however old your installed package is, so prefer this call when a newly added language matters.

Auch verfügbar über

API
GET /languages
TypeScript
languages.list()
Ruby
languages.list
CLI
openemail languages list