Import dictionary entries in dic file

By this time I know that just saving the entries in the dic file of libre office will not work; it will be replaced by a blank file. People said, that is something related to encoding issue. But is there no other way to batch import entries in libre office dictionary file?

By this time I know that just saving the entries in the dic file of libre office will not work; it will be replaced by a blank file. People said, that is something related to encoding issue

The starting premise of the question is false; so I won’t try to answer the asked question (i.e., are there other ways) directly, but instead tell how to add entries to the dic file.

The dic file has the following structure:

OOoUserDict1
lang: <none>
type: positive
---
<entries go here><separated by CR or CRLF>

It is a UTF-8-encoded plain-text file without BOM, which may be edited by any plain-text editor that supports that encoding (on Windows, e.g., I use Notepad++). (Batch-)adding entries after the three hyphens works fine for me.

Windows’ standard Notepad isn’t suitable for the task, because it cannot save UTF-8 without BOM.

Ok, it sounds like, someone really able to help is here. Sorry for the initial wrong information.

But I really tried to include entries manually and save it, which resulted in a blank file after libre office is opened. What I did-

opened the custom dictionary file with notepad on windows. Placed each word in each row. saved it with utf-8 encoding. That failed.

Later I did the same thing with libre office writer. Saved multiple times with different encoding- saved as text file utf-7, utf-8, utf-16. Renamed the files with .dic extension. Nothing worked. Every time it was placed by a new standard.dic file. When I was creating dic files with writer the option cr and lf was selected. Even though the created dic files with manually put entries did not work.

Then I created a new .dic file. But after opening writer, i could not find that listed under user-defined dictionaries.

I even attempted creating a new dic file from there. Then open that in notepad to put entries. Saved that in utf-8. No luck.

What to do now?

Strange. What you did is unclear and looks weird.

I tried to modify the file en-US.dic in the folder LibreOffice/share/extensions/dict-en, and I succeeded to add a word that was recognized by LibreOffice when I relaunched it.

But, the better way to add words you need is to go to Menu Tools > Options > Language Settings > Writing aids, then you click on New… in the user-defined dictionaries section. You set the language you need, then you add what you need.

Then, when writing a text, if you type a word that is not recognized by the spellchecker, you can add it to your custom dictionary with a right-click Menu entry > Add to dictionary > Your dictionary.

Edit:

To update a dictionary by script, you can create your own dictionary extension and install it via unopkg.

The syntax is
unopkg add -f your_dictionary_extension.oxt

The extension identifier should be the same than the one your language already uses, and unopkg will override the bundled extension.

https://api.libreoffice.org/docs/tools.html#unopkg

To create your own dictionary extension, the best way is to copy/paste the existing extension for your language and edit it.

The user wants batch import - which is making multiple changes at once, and using the dialog is not the best way.

Still - yes, adding to the file does work, if you use a suitable plain text editor.

Well, I missed that point… I update my answer.