Client
This section contains the reference for the implementation of translate-md's SpanglishClient
.
SpanglishClient ¶
Client to interact with the Spanglish service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL where the service is exposed. Defaults to SPANGLISH_URL. |
SPANGLISH_URL
|
translate ¶
translate_batch ¶
Translates a batch of texts.
Instead of calling repeatedly on a loop the method translate
,
this method should be preferred, send a list of texts to
translate and get them back in the same order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texts |
list[str]
|
Texts to translate |
required |
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: list of texts translated. |
Examples:
translate_file ¶
Takes the filename of a markdown file in disk and processes to obtain the paragraphs which contain text, sends them to translate them and replaces the new text. Finally writes the new document to disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
Path
|
Path to the markdown file. |
required |
new_filename |
Optional[Path]
|
Filename for the new markdown file to be generated. Defaults to None, in which case it is generated internally. |
None
|