File tree 3 files changed +40
-1
lines changed
3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [ Unreleased]
9
9
### Added
10
- * Add ` Translator.get_glossary_languages() ` to query language pairs supported for glossaries.
10
+ * Add ` Translator.get_glossary_languages() ` to query language pairs supported for glossaries.
11
+ * Add constants for all supported languages codes, for example: ` Language.GERMAN ` .
11
12
### Changed
12
13
* Internal language caching and client-side checking of language codes are removed.
13
14
### Deprecated
Original file line number Diff line number Diff line change @@ -302,6 +302,35 @@ def remove_regional_variant(language: Union[str]) -> str:
302
302
"""Removes the regional variant from a language, e.g. EN-US gives EN"""
303
303
return str (language ).upper ()[0 :2 ]
304
304
305
+ BULGARIAN = "bg"
306
+ CZECH = "cs"
307
+ DANISH = "da"
308
+ GERMAN = "de"
309
+ GREEK = "el"
310
+ ENGLISH = "en" # Only usable as a source language
311
+ ENGLISH_BRITISH = "en-GB" # Only usable as a target language
312
+ ENGLISH_AMERICAN = "en-US" # Only usable as a target language
313
+ SPANISH = "es"
314
+ ESTONIAN = "et"
315
+ FINNISH = "fi"
316
+ FRENCH = "fr"
317
+ HUNGARIAN = "hu"
318
+ ITALIAN = "it"
319
+ JAPANESE = "ja"
320
+ LITHUANIAN = "lt"
321
+ LATVIAN = "lv"
322
+ DUTCH = "nl"
323
+ POLISH = "pl"
324
+ PORTUGUESE = "pt" # Only usable as a source language
325
+ PORTUGUESE_BRAZILIAN = "pt-BR" # Only usable as a target language
326
+ PORTUGUESE_EUROPEAN = "pt-PT" # Only usable as a target language
327
+ ROMANIAN = "ro"
328
+ RUSSIAN = "ru"
329
+ SLOVAK = "sk"
330
+ SLOVENIAN = "sl"
331
+ SWEDISH = "sv"
332
+ CHINESE = "zh"
333
+
305
334
306
335
class GlossaryLanguagePair :
307
336
"""Information about a pair of languages supported for DeepL glossaries.
Original file line number Diff line number Diff line change @@ -28,6 +28,15 @@ def test_example_translation(lang, translator):
28
28
assert "proton" in result_text
29
29
30
30
31
+ def test_translate_with_enums (translator ):
32
+ result = translator .translate_text (
33
+ example_text ["EN" ],
34
+ source_lang = deepl .Language .ENGLISH ,
35
+ target_lang = deepl .Language .GERMAN ,
36
+ )
37
+ assert example_text ["DE" ] == result .text
38
+
39
+
31
40
def test_invalid_authkey (server ):
32
41
translator = deepl .Translator ("invalid" , server_url = server .server_url )
33
42
with pytest .raises (deepl .exceptions .AuthorizationException ):
You can’t perform that action at this time.
0 commit comments