![]() Format and default are the same as for splitting_tags.įor a detailed explanation of the XML handling options, see the ignore_tags: list of XML tags that containing content that should not be.Format and default are the same as for splitting_tags. non_splitting_tags: list of XML tags that should not be used to split text.Or a comma-separated list of strings ( 'tag1,tag2'). Tags may be specified as an array of strings ( ), splitting_tags: list of XML tags that should be used to split text into.outline_detection: specify False to disable automatic tag detection,.The following options are only used if tag_handling is 'xml': tag_handling: type of tags to parse before translation, options are 'html'.glossary: specifies a glossary to use with translation, either as a stringĬontaining the glossary ID, or a GlossaryInfo as returned by.'more' ( Formality.MORE): use formal, more polite language.'less' ( Formality.LESS): use informal language.This option is only available for some target languages, see formality: controls whether translations should lean toward informal orįormal language.To prevent automatic-correction of formatting, default: False. preserve_formatting: controls automatic-formatting-correction.Into sentences using punctuation but not newlines. 'nonewlines' ( SplitSentences.NO_NEWLINES): input text will be split.Use this for applications where each input text contains only 'off' ( SplitSentences.OFF): input text will not be split into.'on'' ( SplitSentences.ON): input text will be split into sentences.split_sentences: specify how input text should be split into sentences,.source_lang: Specifies the source language code, but may be omitted to.In addition to the input text(s) argument, the available translate_text() ) # 'Wie geht es Ihnen?' Text translation options "How are you?", target_lang = "DE", formality = "more" "How are you?", target_lang = "DE", formality = "less" detected_source_lang) # "ES" the language code for Spanish # Translate into German with less and more Formality: print( detected_source_lang) # "JA" the language code for Japanese print( result. text) # "Bonjour, le monde !" # Translate multiple texts into British English result = translator. translate_text( "Hello, world!", target_lang = "FR") # Translate text into a target language, in this case, French: result = translator. The translated text, and detected_source_lang is the detected source language Translate_text() returns a TextResult, or a list of TextResultsĬorresponding to your input text(s). There are additional optional arguments to control translation, see ![]() Variant according to ISO 3166-1, for example 'EN-US', or 'PT-BR'. Some target languages also include the regional Language codes are case-insensitive strings according to ISO 639-1, forĮxample 'DE', 'FR', 'JA''. The source_lang is optional, if it is unspecified the source Source_lang and target_lang specify the source and target language codes The first argument is a stringĬontaining the text you want to translate, or a list of strings if you want to To translate text, call translate_text(). Translator accepts additional options, see Configuration In production code, theĪuthentication key should not be hard-coded, but instead fetched from aĬonfiguration file or environment variable. This example is for demonstration purposes only. ![]() Import deepl auth_key = "f63c02c5-f056-." # Replace with your key translator = deepl. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |