Crate dptran

Source

Structs§

DpTranUsage
DeepL API usage information
character_count: Number of characters translated this month
character_limit: Maximum number of characters that can be translated this month
If character_limit is 0, it is unlimited

Enums§

ConnectionError
ConnectionError
It is an error that occurs when communicating with the DeepL API.
BadRequest: 400 Bad Request
Forbidden: 403 Forbidden
NotFound: 404 Not Found
RequestEntityTooLarge: 413 Request Entity Too Large
TooManyRequests: 429 Too Many Requests
UnprocessableEntity: 456 Unprocessable Entity
ServiceUnavailable: 503 Service Unavailable
CurlError: Curl Error
UnknownError: Unknown Error
DeeplAPIError
DeepL API error.
ConnectionError: Connection error occurred in the process of sending and receiving data.
JsonError: Error occurred while parsing json.
LimitError: The translation limit of your account has been reached. Consider upgrading your subscription.
GetLanguageCodesError: Could not get language codes.
DpTranError
Errors that can occur in this library.
DeeplApiError: DeepL API error
InvalidLanguageCode: Invalid language code
ApiKeyIsNotSet: API key is not set
NoTargetLanguageSpecified: No target language specified
CouldNotGetInputText: Could not get input text
LangType
Target / Source language types
used in get_language_codes()

Functions§

check_language_code
Check the validity of language codes. Using DeepL API.
api_key: DeepL API key
lang_code: Language code to check
lang_type: Target or Source
correct_source_language_code
Convert to correct language code from input source language code string. Using DeepL API.
api_key: DeepL API key
language_code: Language code to convert
Caution: EN, PT are not automatically converted to EN-US, PT-PT from version 2.1.0.
correct_target_language_code
Convert to correct language code from input target language code string. Using DeepL API. api_key: DeepL API key language_code: Language code to convert Caution: EN, PT are not automatically converted to EN-US, PT-PT from version 2.1.0.
get_language_codes
Get language code list. Using DeepL API.
Retrieved from https://api-free.deepl.com/v2/languages.
api_key: DeepL API key
lang_type: Target or Source
get_usage
Get the number of characters remaining to be translated. Using DeepL API.
Retrieved from https://api-free.deepl.com/v2/usage.
Returns an error if acquisition fails.
api_key: DeepL API key
translate
Display translation results. Using DeepL API.
Receive translation results in json format and display translation results.
Return error if json parsing fails.
api_key: DeepL API key
text: Text to translate
target_lang: Target language
source_lang: Source language (optional)

Type Aliases§

LangCode
string as language code
LangCodeName
Language code and language name