Information about a language supported by DeepL translator. :param code: Language code according to ISO 639-1, for example "EN". Some target languages also include the regional variant according to ISO 3166-1, for example "EN-US". :param name: Name of the language in English
| 227 | |
| 228 | |
| 229 | class Language: |
| 230 | """Information about a language supported by DeepL translator. |
| 231 | |
| 232 | :param code: Language code according to ISO 639-1, for example "EN". |
| 233 | Some target languages also include the regional variant according to |
| 234 | ISO 3166-1, for example "EN-US". |
| 235 | :param name: Name of the language in English. |
| 236 | :param supports_formality: (Optional) Specifies whether the formality |
| 237 | option is available for this language; target languages only. |
| 238 | """ |
| 239 | |
| 240 | def __init__( |
| 241 | self, code: str, name: str, supports_formality: Optional[bool] = None |
| 242 | ): |
| 243 | self.code = code |
| 244 | self.name = name |
| 245 | self.supports_formality = supports_formality |
| 246 | |
| 247 | def __str__(self): |
| 248 | return self.code |
| 249 | |
| 250 | @staticmethod |
| 251 | def remove_regional_variant(language: Union[str, "Language"]) -> str: |
| 252 | """Removes the regional variant from a language, e.g. EN-US gives EN""" |
| 253 | dash_index = str(language).find("-") |
| 254 | if dash_index != -1: |
| 255 | return str(language).upper()[0:dash_index] |
| 256 | else: |
| 257 | return str(language).upper() |
| 258 | |
| 259 | ACEHNESE = "ace" |
| 260 | AFRIKAANS = "af" |
| 261 | ARAGONESE = "an" |
| 262 | ARABIC = "ar" |
| 263 | ASSAMESE = "as" |
| 264 | AYMARA = "ay" |
| 265 | AZERBAIJANI = "az" |
| 266 | BASHKIR = "ba" |
| 267 | BELARUSIAN = "be" |
| 268 | BULGARIAN = "bg" |
| 269 | BHOJPURI = "bho" |
| 270 | BENGALI = "bn" |
| 271 | BRETON = "br" |
| 272 | BOSNIAN = "bs" |
| 273 | CATALAN = "ca" |
| 274 | CEBUANO = "ceb" |
| 275 | KURDISH_SORANI = "ckb" |
| 276 | CZECH = "cs" |
| 277 | WELSH = "cy" |
| 278 | DANISH = "da" |
| 279 | GERMAN = "de" |
| 280 | GREEK = "el" |
| 281 | ENGLISH = "en" # Only usable as a source language |
| 282 | ENGLISH_BRITISH = "en-GB" # Only usable as a target language |
| 283 | ENGLISH_AMERICAN = "en-US" # Only usable as a target language |
| 284 | ESPERANTO = "eo" |
| 285 | SPANISH = "es" |
| 286 | SPANISH_LATIN_AMERICAN = "es-419" # Only usable as a target language |
no outgoing calls
no test coverage detected