183 lines
11 KiB
TypeScript
183 lines
11 KiB
TypeScript
import { Translator } from './translator';
|
|
import { SourceLanguageCode, DeepLClientOptions, WriteResult, MultilingualGlossaryDictionaryEntries, MultilingualGlossaryInfo, MultilingualGlossaryDictionaryInfo, GlossaryId } from './types';
|
|
export declare enum WritingStyle {
|
|
ACADEMIC = "academic",
|
|
BUSINESS = "business",
|
|
CASUAL = "casual",
|
|
DEFAULT = "default",
|
|
PREFER_ACADEMIC = "prefer_academic",
|
|
PREFER_BUSINESS = "prefer_business",
|
|
PREFER_CASUAL = "prefer_casual",
|
|
PREFER_SIMPLE = "prefer_simple",
|
|
SIMPLE = "simple"
|
|
}
|
|
export declare enum WritingTone {
|
|
CONFIDENT = "confident",
|
|
DEFAULT = "default",
|
|
DIPLOMATIC = "diplomatic",
|
|
ENTHUSIASTIC = "enthusiastic",
|
|
FRIENDLY = "friendly",
|
|
PREFER_CONFIDENT = "prefer_confident",
|
|
PREFER_DIPLOMATIC = "prefer_diplomatic",
|
|
PREFER_ENTHUSIASTIC = "prefer_enthusiastic",
|
|
PREFER_FRIENDLY = "prefer_friendly"
|
|
}
|
|
export declare class DeepLClient extends Translator {
|
|
constructor(authKey: string, options?: DeepLClientOptions);
|
|
rephraseText<T extends string | string[]>(texts: T, targetLang: SourceLanguageCode | null, writingStyle?: string | null, tone?: string | null): Promise<T extends string ? WriteResult : WriteResult[]>;
|
|
/**
|
|
* Creates a glossary with given name with all of the specified
|
|
* dictionaries, each with their own language pair and entries. The
|
|
* glossary may be used in the translateText functions.
|
|
*
|
|
* Only certain language pairs are supported. The available language pairs
|
|
* can be queried using getGlossaryLanguages(). Glossaries are not
|
|
* regional specific: a glossary with target language EN may be used to
|
|
* translate texts into both EN-US and EN-GB.
|
|
*
|
|
* This function requires the glossary entries for each dictionary to be
|
|
* provided as a dictionary of source-target terms. To create a glossary
|
|
* from a CSV file downloaded from the DeepL website, see
|
|
* {@link createMultilingualGlossaryWithCsv}.
|
|
*
|
|
* @param name user-defined name to attach to glossary.
|
|
* @param glossaryDicts the dictionaries of the glossary, see {@link MultilingualGlossaryDictionaryEntries}.
|
|
* @return {Promise<MultilingualGlossaryInfo>} object with details about the newly created glossary.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API
|
|
*/
|
|
createMultilingualGlossary(name: string, glossaryDicts: MultilingualGlossaryDictionaryEntries[]): Promise<MultilingualGlossaryInfo>;
|
|
/**
|
|
* Creates a multilingual glossary with the given name using entries from a CSV file.
|
|
* The CSV file must contain two columns: source terms and target terms.
|
|
* The glossary may be used in the translateText() functions.
|
|
*
|
|
* Only certain language pairs are supported. The available language pairs
|
|
* can be queried using getGlossaryLanguages(). Glossaries are not
|
|
* regional specific: a glossary with target language EN may be used to
|
|
* translate texts into both EN-US and EN-GB.
|
|
*
|
|
* @param name User-defined name to attach to the glossary.
|
|
* @param sourceLanguageCode Source language code for the glossary.
|
|
* @param targetLanguageCode Target language code for the glossary.
|
|
* @param csvContent String in CSV format containing the entries.
|
|
* @returns {Promise<MultilingualGlossaryInfo>} Object with details about the newly created glossary.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
createMultilingualGlossaryWithCsv(name: string, sourceLanguageCode: string, targetLanguageCode: string, csvContent: string): Promise<MultilingualGlossaryInfo>;
|
|
/**
|
|
* Retrieves information about the glossary with the specified ID.
|
|
* This does not retrieve the glossary entries.
|
|
* @param glossaryId ID of glossary to retrieve.
|
|
* @returns {Promise<MultilingualGlossaryInfo>} object with details about the specified glossary.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
getMultilingualGlossary(glossaryId: string): Promise<MultilingualGlossaryInfo>;
|
|
/**
|
|
* Retrieves the dictionary entries for a specific glossary and language pair.
|
|
*
|
|
* If the source and target language codes are specified, there should be at most one dictionary returned.
|
|
*
|
|
* @param glossary The ID of the glossary or MultilingualGlossaryInfo object to query.
|
|
* @param sourceLanguageCode Source language code of the dictionary.
|
|
* @param targetLanguageCode Target language code of the dictionary.
|
|
* @returns {Promise<MultilingualGlossaryDictionaryEntries>} Object containing the dictionary entries.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
* @throws {GlossaryNotFoundError} If no dictionary is found for the given source and target language codes.
|
|
*/
|
|
getMultilingualGlossaryDictionaryEntries(glossary: GlossaryId | MultilingualGlossaryInfo, sourceLanguageCode: string, targetLanguageCode: string): Promise<MultilingualGlossaryDictionaryEntries>;
|
|
/**
|
|
* Retrieves a list of all multilingual glossaries available for the authenticated user.
|
|
*
|
|
* @returns {Promise<MultilingualGlossaryInfo[]>} An array of objects containing details about each glossary.
|
|
*
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
listMultilingualGlossaries(): Promise<MultilingualGlossaryInfo[]>;
|
|
/**
|
|
* Deletes the glossary with the specified ID or MultilingualGlossaryInfo object.
|
|
* @param glossary The ID of the glossary or MultilingualGlossaryInfo object to delete.
|
|
* @throws {Error} If the glossaryId is empty.
|
|
* @throws {DeepLError} If the glossary could not be deleted.
|
|
*/
|
|
deleteMultilingualGlossary(glossary: GlossaryId | MultilingualGlossaryInfo): Promise<void>;
|
|
/**
|
|
* Deletes a specific dictionary from a multilingual glossary based on the source and target language codes.
|
|
*
|
|
* @param glossary ID of the glossary or MultilingualGlossaryInfo object from which the dictionary will be deleted.
|
|
* @param sourceLanguageCode Source language code of the dictionary to delete.
|
|
* @param targetLanguageCode Target language code of the dictionary to delete.
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
deleteMultilingualGlossaryDictionary(glossary: GlossaryId | MultilingualGlossaryInfo, sourceLanguageCode: string, targetLanguageCode: string): Promise<void>;
|
|
/**
|
|
* Replaces the dictionary entries for a specific source and target language pair in a multilingual glossary.
|
|
*
|
|
* @param glossary ID of the glossary or MultilingualGlossaryInfo object from which the dictionary will be deleted.
|
|
* @param sourceLanguageCode Source language code of the dictionary to replace.
|
|
* @param targetLanguageCode Target language code of the dictionary to replace.
|
|
* @param entries Dictionary entries to replace, formatted as a string in TSV format.
|
|
* @returns {Promise<MultilingualGlossaryDictionaryInfo>} Object containing details about the updated dictionary.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
replaceMultilingualGlossaryDictionary(glossary: GlossaryId | MultilingualGlossaryInfo, glossaryDict: MultilingualGlossaryDictionaryEntries): Promise<MultilingualGlossaryDictionaryInfo>;
|
|
/**
|
|
* Replaces the dictionary entries for a specific source and target language pair in a multilingual glossary
|
|
* using entries from a CSV file.
|
|
*
|
|
* @param glossary ID of the glossary or MultilingualGlossaryInfo object from which the dictionary will be deleted.
|
|
* @param sourceLanguageCode Source language code of the dictionary to replace.
|
|
* @param targetLanguageCode Target language code of the dictionary to replace.
|
|
* @param csvContent String in CSV format containing the new entries.
|
|
* @returns {Promise<MultilingualGlossaryDictionaryInfo>} Object containing details about the updated dictionary.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
replaceMultilingualGlossaryDictionaryWithCsv(glossary: GlossaryId | MultilingualGlossaryInfo, sourceLanguageCode: string, targetLanguageCode: string, csvContent: string): Promise<MultilingualGlossaryDictionaryInfo>;
|
|
/**
|
|
* Updates the name of a multilingual glossary.
|
|
*
|
|
* @param glossary ID of the glossary or MultilingualGlossaryInfo object from which the dictionary will be deleted.
|
|
* @param name New name for the glossary.
|
|
* @returns {Promise<MultilingualGlossaryInfo>} Object containing details about the updated glossary.
|
|
*
|
|
* @throws {ArgumentError} If the name is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
updateMultilingualGlossaryName(glossary: GlossaryId | MultilingualGlossaryInfo, name: string): Promise<MultilingualGlossaryInfo>;
|
|
/**
|
|
* Updates the dictionary entries for a specific source and target language pair in a multilingual glossary.
|
|
*
|
|
* @param glossary ID of the glossary or MultilingualGlossaryInfo object to update.
|
|
* @param glossaryDict The new or updated glossary dictionary.
|
|
* @returns {Promise<MultilingualGlossaryInfo>} Object containing details about the updated glossary.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
updateMultilingualGlossaryDictionary(glossary: GlossaryId | MultilingualGlossaryInfo, glossaryDict: MultilingualGlossaryDictionaryEntries): Promise<MultilingualGlossaryInfo>;
|
|
/**
|
|
* Updates the dictionary entries for a specific source and target language pair in a multilingual glossary
|
|
* using entries from a CSV file.
|
|
*
|
|
* @param glossary ID of the glossary or MultilingualGlossaryInfo object to update.
|
|
* @param sourceLanguageCode Source language code of the dictionary to update.
|
|
* @param targetLanguageCode Target language code of the dictionary to update.
|
|
* @param csvContent String in CSV format containing the new entries.
|
|
* @returns {Promise<MultilingualGlossaryInfo>} Object containing details about the updated glossary.
|
|
*
|
|
* @throws {ArgumentError} If any argument is invalid.
|
|
* @throws {DeepLError} If any error occurs while communicating with the DeepL API.
|
|
*/
|
|
updateMultilingualGlossaryDictionaryWithCsv(glossary: GlossaryId | MultilingualGlossaryInfo, sourceLanguageCode: string, targetLanguageCode: string, csvContent: string): Promise<MultilingualGlossaryInfo>;
|
|
}
|