Sunday, June 30, 2013

How to make your own Stardict/Goldendict compatible dictionary

I recently found a PDF online of a fairly decent Ojibwe<>English dictionary that I wanted to incorporate into my list of dictionaries that I use on my system. I currently use Goldendict, which is compatible with Stardict, because it easily incorporates itself in my system and is usable with any application. Both Stardict and Goldendict are currently available for both Windows and Linux. Since I primarily use Ubuntu, both packages are available in the standard repository to install, but there are also installation packages located at the Startdict Project Google Code page. In any case, if you've already installed either Stardict or Goldendict, you'll want to grab stardict-tools (for Linux users) or stardict-editor (for Windows users) and install it.

I'll go through the steps to convert the PDF file to something that can be used within Stardict and Goldendict.

First, you want to create a simple text file with the dictionary. I just copied and pasted all the text I wanted to include into a new text file:


You'll notice that the delimiter between the two languages is a dash. I needed to change that to something that the convert program could understand. I chose a [TAB] as the delimiter. I also made sure to put a space before and after my dash, because Ojibwe uses dashes with some affixes.


I then saved that file as a text file. Once the file was saved, I then called up stardict-editor. This is a simple, single-window application that will do the conversion to a compatible format for use in the Stardict and Goldendict applications.



Click on the "Browse" button to load your saved newly edited text file, then click "Compile". If all goes well, you'll get the following dialog:




I had hundreds of duplicate entries, because the particular dictionary I'm using includes other dialects, and some of the entries were the same for the various dialects. If there are duplicates, an error is shown with a line number. Simply go back and fix/delete the entry, then try again until you get the above dialog.

Once compiled, three files will be created, a dict.dx, .idx, and .ifo file:


Next we want to open the .ifo file in a text editor and change the name of the dictionary to what we want it to be:


This name is what will be visible in the dictionary application.

Save the file and then start Stardict or Goldendict. Make sure that all three of these newly created files are easily accessible to the dictionary program. On my system there is a global user location, and I've also created my own dictionary directory and place all my own user-created dictionaries there.

Now we want to let the application know where the dictionaries are located. Start Goldendict (what I use), go to "Edit... Dictionaries". The following dialog box will appear:


Click on "Rescan". Now click on the "Dictionaries tab in the same dialog box, and you should see your new dictionary recognized.


That's it . You're done! You can now use your new dictionary.


The above screenshot is a simple dictionary lookup, but what makes Stardict and Goldendict so useful is that it can be used with any text application. While you're reading along in an epub, PDF, text program, you can just click on any word and you'll get the definition for it, provided it's in the dictionary:


Keep in mind that this process needs to be done for each language direction. The screenshots I've included here only show the process for an Ojibwe > English dictionary. The same thing must be done if you want a dictionary for the other direction (English > Ojibwe in my case).

I don't know of any direct way to do this for a Mac, but I know that there is something that will convert an already created Stardict/Goldendict dictionary to Mac Dictionary format. It's called the Mac Dictionary Kit and includes DictUnifier. It can be found here.

14 comments:

  1. Thanks for your writing, but i'm searching how to customize my dictionary: i want to add the images and as i see in your example, a word has one meaning. If i want to add more level of meaning, is it possible?


    Thankyou

    ReplyDelete
    Replies
    1. In the file .tab, use the mark-up Pango (search in Wikipedia).

      Delete
  2. Thanks, this is very useful. Stardict can apparently make use of more complex dictionary files with added features such as including an audio file to play, but it looks like you have to create the necessary files manually in order to do this. Is there by any chance a way to use stardict-editor to create dictionaries with audio and other such features?

    ReplyDelete
  3. when I try to compile in stardict editor I get this

    Building...
    Error, no new line at the end.
    Failed!

    Someone told me here http://askubuntu.com/questions/810407/stardict-goldend-abiword that I need an enter to add in html file , I dont know what is meant...

    I tried everything but I always get en error, can someone solve my problem.

    Thanks in advance.

    ReplyDelete
    Replies
    1. Did you try adding a carriage return at the the end... to create a new line?

      Delete
  4. > I had hundreds of duplicate entries, because the particular dictionary I'm using includes other dialects, and some of the entries were the same for the various dialects. If there are duplicates, an error is shown with a line number. Simply go back and fix/delete the entry, then try again until you get the above dialog.

    If you use the version 3.0.1 you wont have this problem

    ReplyDelete
  5. Hi, I can't find the stardict editor anywhere, i'm using windows 10, where can I get it ?

    ReplyDelete
    Replies
    1. For windows, I also looked it up everywhere and I have not been able to run any of the versions I found (https://code.google.com/archive/p/stardictproject/downloads and https://github.com/lpdevs/free-dictionaries)

      Delete
    2. Actually, it worked! I used https://github.com/lpdevs/free-dictionaries, followed the instructions but put editor.exe in the same root as gtk2 to run it. I had to download the iconv.dll file from here: https://gnupg.org/download/iconv.html. I also put it in the same root (gtk2/bin)and now it works fine :))
      I was able to generate my own dictionary

      Delete
  6. can we add image after word definition ?

    ReplyDelete
  7. Thank you so much as you have been willing to share information with us. top 10 boarding school in delhi We will forever admire all you have done here because you have made my work as easy as ABC.

    ReplyDelete
  8. For the "Error, no new line at the end." I found that a control character was inserted at the end of a line. I deleted it, then compilation worked. The control character is 26 (Control-Z, SUB, EOF, ^Z) (see wikipedia). Try to find it in your document copying from here: . (here appear as an arrow; In Emeditor appeared as a Z, Notepad++ as SUB, and in Notepad doesn't appear anymore).

    ReplyDelete
  9. Hi! I cannot file a gui stardicteditor for linux, can you share the link of the stardict-editor one that you are using in this article?

    ReplyDelete