@@ -450,7 +450,8 @@ const glossaryEnToDe = await deeplClient.createMultilingualGlossary('My glossary
450450```
451451
452452You can also upload a glossary downloaded from the DeepL website using
453- ` createGlossaryWithCsv() ` . Instead of supplying the entries as a dictionary,
453+ ` createMultilingualGlossaryFromCsv() ` (` createMultilingualGlossaryWithCsv() ` is
454+ deprecated and behaves the same). Instead of supplying the entries as a dictionary,
454455provide the CSV content as a string.
455456
456457``` javascript
@@ -464,7 +465,7 @@ try {
464465 throw error;
465466}
466467const csvContent = await readCsvFile (filePath);
467- const glossaryEnToDe = await deeplClient .createMultilingualGlossaryWithCsv (' My glossary' , ' en' , ' de' , csvContent);
468+ const glossaryEnToDe = await deeplClient .createMultilingualGlossaryFromCsv (' My glossary' , ' en' , ' de' , csvContent);
468469```
469470
470471The [ API documentation] [ api-docs-csv-format ] explains the expected CSV format in
@@ -501,7 +502,8 @@ console.log(resultWithGlossary.text); // 'Der Maler wurde mit einem Gewinn ausge
501502
502503Functions to get, list, and delete stored glossaries are also provided:
503504
504- - ` getMultilingualGlossary() ` takes a glossary ID and returns a
505+ - ` getMultilingualGlossary() ` takes a glossary ID or ` MultilingualGlossaryInfo `
506+ object and returns a
505507 ` Promise<MultilingualGlossaryInfo> ` object for a stored glossary, or raises an
506508 exception if no such glossary is found.
507509- ` listMultilingualGlossaries() ` returns a promise of a list of ` MultilingualGlossaryInfo ` objects
@@ -548,6 +550,11 @@ console.log(entriesObj.entries.toTsv()); // 'hello\thallo'
548550
549551Functions to edit stored glossaries are also provided:
550552
553+ - ` updateMultilingualGlossary() ` takes a glossary ID or ` MultilingualGlossaryInfo `
554+ object and an optional ` UpdateMultilingualGlossaryOptions ` with ` name ` and
555+ ` dictionaries ` , and changes the name and merges the dictionaries in one request.
556+ Only the fields that are set are sent. The methods below are shortcuts for one
557+ field.
551558- ` updateMultilingualGlossaryDictionary() ` takes a glossary ID or ` MultilingualGlossaryInfo `
552559 object, plus a source language, target language, and a dictionary of entries.
553560 It will then either update the list of entries for that dictionary (either
@@ -560,12 +567,26 @@ Functions to edit stored glossaries are also provided:
560567 replacing any pre-existing entries for that language pair.
561568- ` updateMultilingualGlossaryName() ` takes a glossary ID or ` MultilingualGlossaryInfo `
562569 object, plus the new name of the glossary.
570+ - ` updateMultilingualGlossaryDictionaryFromCsv() ` and
571+ ` replaceMultilingualGlossaryDictionaryFromCsv() ` take a glossary ID or
572+ ` MultilingualGlossaryInfo ` object, a source language, target language and the
573+ entries as CSV content. The ` *WithCsv() ` methods of the same name are
574+ deprecated and behave the same.
575+
576+ Every method that takes a glossary accepts its ID or a ` MultilingualGlossaryInfo `
577+ object. The methods that send a request body (` createMultilingualGlossary() ` ,
578+ ` createMultilingualGlossaryFromCsv() ` , ` updateMultilingualGlossary() ` , the
579+ ` updateMultilingualGlossary*() ` shortcuts and ` replaceMultilingualGlossaryDictionary*() ` )
580+ take an optional last ` options ` argument with ` extraBodyParameters ` : extra fields
581+ added last to the request body, replacing fields of the same name.
563582
564583``` javascript
565584const glossaryDicts = [{sourceLangCode: ' en' , targetLangCode: ' de' , entries: new deepl.GlossaryEntries ({ entries: {" artist" : " Maler" , " hello" : " guten tag" } })}];
566585const myGlossary = await deeplClient .createMultilingualGlossary (' My Glossary' , glossaryDicts);
567586const newDict = {sourceLangCode: ' en' , targetLangCode: ' de' , entries: new deepl.GlossaryEntries ({ entries: {" hello" : " hallo" , " prize" : " Gewinn" } })};
568587const updatedGlossary = await deeplClient .updateMultilingualGlossaryDictionary (myGlossary, newDict);
588+ // Rename the glossary and merge entries in one request
589+ await deeplClient .updateMultilingualGlossary (myGlossary, { name: ' My renamed glossary' , dictionaries: [newDict] });
569590
570591const entriesObj = await deeplClient .getMultilingualGlossaryDictionaryEntries (createdGlossary, ' en' , ' de' );
571592console .log (entriesObj .entries .toTsv ()); // {'artist': 'Maler', 'hello': 'hallo', 'prize': 'Gewinn'}
0 commit comments