gdcl icon indicating copy to clipboard operation
gdcl copied to clipboard

Read preferences from GoldenDict config file

Open dohliam opened this issue 10 years ago • 0 comments

Currently gdcl uses gdcg.rb to prepare custom groups of dictionaries for searching. Ideally, gdcl should look in the GoldenDict home folder and read the preferences in the GoldenDict config file so that we can use groups that have already been set up by the user.

The config file is relatively simple and the groups are arranged under <group> tags, e.g.:

  <group id="1" name="zh">

followed by a list of dictionaries between dictionary tags, e.g.:

   <dictionary name="Chinese Wikipedia">935a97e41606b54a232c18374b15754b</dictionary>

The only problem is that, as seen in the example above, the dictionaries are listed by their index hash rather than file name or location. So to get the file location we need to first read the preferences folder to discover the group name, and then get the location and other information from the index file.

Unfortunately, the index file is encoded, so we need to decode the file to read the location information. It is not immediately obvious how to do that, but someone more familiar with the GoldenDict source code might be able to help.

dohliam avatar Feb 28 '15 23:02 dohliam