Home Software Contact Links RecentChanges MyBlog

RDictCc

Overview

RDictCc is a german-english (and vice versa) word translator. It uses the dictionary you can fetch from http://www.dict.cc. RDictCc has a tight integration into Emacs and is free software released under the GPLv3.

News

Version 7.0.1 out now! (2009/01/04). Only some docfixes.


Version 7.0.0 out now! (2008/12/12). Refactoring of the emacs addon: New variable: rdictcc-show-translation-functions, Deleted: rdictcc-show-translations-in-buffer, rdictcc-show-translations-in-tooltips


Version 6.2.5 out now! (2008/09/30). SPC in *rdictcc* replaces the translated word with the whole translation line.


Requirements

Importing the dictionary file

The first step you have to do is importing the dictionary file you downloaded from http://www.dict.cc. This will build two DBM database files in ~/.rdictcc. So here we go:

# Import the dict file downloaded from dict.cc. (This has to be
# done only one time, or if you downloaded a new dict file.)
$ rdictcc.rb --import ~/dict-file.txt [snipped output]
** Reading dict file (de)
** built dict with 134890 entries
** Going to delete old database /home/heimdall/.rdictcc/dict_de.dbm
** Deleted old database /home/heimdall/.rdictcc/dict_de.dbm
** writing database file...
Stored 1000 / 134890 values
[...]
Stored 134000 / 134890 values
** Database building done!
** Reading dict file (en)
** built dict with 81901 entries
** Going to delete old database /home/heimdall/.rdictcc/dict_en.dbm
** Deleted old database /home/heimdall/.rdictcc/dict_en.dbm
** writing database file...
Stored 1000 / 81901 values
[...]
Stored 81000 / 81901 values
** Database building done!

After this initial step you can ask rdictcc.rb to translate a given word, all words matching the given regular expression or all sentences matching the given regular expression (new!).

Usage Examples

Word translations are the most simple queries and can be done in constant time.

$ rdictcc.rb flasche
DE-EN Translations:
===================
Flasche {f}:
    - bottle
    - flagon
eine Flasche sein:
    - to be a pain in the arse [coll.]
Flasche {f} (Versager):
    - dweeb [Am.]
den Geist aus der Flasche lassen:
    - to let the genie out of the bottle

EN-DE Translations:
===================

Regexp word translations are done by using the option -r or --regexp. They take much longer as the normal word translation.

$ rdictcc.rb -r '^c.w.*d$'
DE-EN Translations:
===================

EN-DE Translations:
===================
cowered:
    - gekauert
    - hockte
cowshed:
    - Kuhstall {m}
cawed:
    - gekrächzt
    - krächzte
cowed:
    - eingeschüchtert
coward:
    - Angsthase {m}
    - feig
    - feige
    - feiger Wicht {m} [ugs.]
    - Feigling {m}
    - Hasenfuß {m} [fig.]
Such a coward!:
    - So ein Feigling!

Fulltext regexp translations are done by using the option -f or --fulltext. In contrast to regexp word translations they match the query against the whole string, not only against the keyword, which is the longest word in the sentence. They take about as long as regexp word translations.

$ rdictcc.rb -f 'shut.*up'
DE-EN Translations:
===================

EN-DE Translations:
===================
Shut the fuck/hell up! [sl.]:
    - Halt dein verdammtes Maul!
Put up evidence or shut up!:
    - Beweise her oder Maul halten!
Will you kindly shut up!:
    - Wollen Sie gefälligst den Mund halten!
STFU : shut the fuck up [vulg.]:
    - Halt die Schnauze!
Shut up!:
    - Gusch! [österr.]
    - Halt den Mund!
Shut the fuck up! [vulg.]:
    - Halt die Fresse! [vulg.]

Since version 5.1 there’s an interactive mode, which performs simple word translations for every word you type. That’s more convenient if you need to translate many words in a row. You exit from interactive mode by typing ^Q (which really is ^ followed by a capital Q, not Ctrl-Q). In interactive mode you can also make regexp word translations by preceding the query string with :r: or fulltext regexp translations by preceding the query string with :f:.

heimdall@baldur ~> rdictcc
Welcome to rdictcc's interactive mode. This mode will read from stdin
and print the translations until it reads ^Q (literally, not Ctrl-Q).
=> Schaf

DE-EN Translations:
===================
Schaf {n}:
    - jumbuck [Aus.] [Aboriginal]
    - sheep

EN-DE Translations:
===================
--------------------------------------------------------------------------------
=> :r:^bi.*k.*gin$

DE-EN Translations:
===================
Bienenkönigin {f}:
    - queen bee

EN-DE Translations:
===================
--------------------------------------------------------------------------------
=> :f:hal.*aul

DE-EN Translations:
===================
Halt dein verdammtes Maul!:
    - Shut the fuck/hell up! [sl.]
Halt's Maul!:
    - Keep your trap shut!
    - Stow it!
Halt's Maul! (fam.):
    - Shut your puss!
Halt's Maul! [vulg.]:
    - Put a sock in it! [sl.]
Erhaltung einer baulichen Anlage:
    - preservation of physical structure

EN-DE Translations:
===================
--------------------------------------------------------------------------------
=> ^Q

Bye.

There are some more interesting options, so check out the online help.

% rdictcc --help
Usage: rdictcc.rb [database_import_options]
       rdictcc.rb [misc_options]
       rdictcc.rb [query_option] QUERY
       rdictcc.rb

If no option nor QUERY is given, you'll enter rdictcc's interactive mode.

Database building options:
    -i, --import DICTCC_FILE         Import the dict file from dict.cc

Misc options:
    -v, --version                    Show rdictcc.rb's version
    -S, --size                       Show the number of entries in the databases
    -d, --directory PATH             Use PATH instead of ~/.rdictcc/
    -h, --help                       Show this message

Format options:
    -c, --compact                    Use compact output format

Query option:
    -s, --simple                     Translate the word given as QUERY (default)
    -r, --regexp                     Translate all words matching the regexp QUERY
    -f, --fulltext                   Translate all sentences matching the regexp QUERY

Problems

Broken Umlauts and Accented Characters

If the translations contains broken characters, open the text file you downloaded from http://www.dict.cc in a text editor like Emacs, Vim or Kate. The file’s encoding is iso-8859-15 (or cp1252??), so switch to this encoding. Normally all characters should be fine then. Now save the file with your system’s coding system, i.e. UTF-8 encoding.

With Emacs it should go like this:

Alternatively you can convert the file to other coding systems using the iconv tool.

iconv -f cp1252 -t utf8 -o dict-conv.txt dict.txt

After that rebuild your DBM database files. (First step, see above.)

I get no translations at all!

This can happen if you switch from QDBM to GDBM or vice versa. Simply delete your old database files in ~/.rdictcc (not really needed, but why not save some disk space?) and rebuild your databases. (First step, see above.)

Getting RDictCc

You can download rdictcc-7.0.1.tar.bz2 here. It contains the program rdictcc.rb described above and an additional emacs lisp file which you can use to smoothly integrate RDictCc into (GNU) Emacs. This integration is documented below.

If you always want to use the bleeding edge version or you want to hack on it, clone my git repository.

git-clone http://www.tsdh.de/repos/git/rdictcc.git

RDictCc Integration into Emacs

If you’re an Emacs guy as I am, you can use the emacs module to translate the word at point or an interactively given word by putting the lines below into your Emacs init file (~/.emacs) and the file rdictcc.el included in the tarball into your emacs load path.

(require 'rdictcc)
;; If the default isn't ok for you.
;; (setq rdictcc-program "/path/to/your/rdictcc.rb")
(global-set-key (kbd "C-c t") 'rdictcc-translate-word-at-point)
(global-set-key (kbd "C-c T") 'rdictcc-translate-word)
;; Translate the word under point at dict.cc or dict.leo.org opening a browser.
(global-set-key (kbd "C-c w") 
                (lambda()
                  (interactive)
                  (rdictcc-webtranslate (word-at-point))))
;; Update the *rdictcc* buffer on point movements
(add-hook 'gnus-article-mode-hook 'rdictcc-permanent-translation-mode)

Be sure to have a look at the variables starting with rdictcc-, because here you can tweak the behavior of most things. There’s a minor mode named rdictcc-tooltip-mode available, which will open a tooltip with the translation of the word your mouse points at. For all tooltip-things you need GNU Emacs, I think.

The translation buffer (rdictcc-buffer) has its own major mode (rdictcc-buffer-mode) which offers useful keybindings. For example you can open a browser and get the online translation for the last word at http://www.dict.cc by simply typing W d. Or if you hit RET on a word in the rdictcc-buffer, the word you translated will be replaced by the chosen translation. For an overview of that mode’s commands type ? while your point is in the rdictcc-buffer.

Screenshots

Here are two screenshots: The first shows the translations displayed in a separate buffer which is the default.

http://www.tsdh.de/images/rdictcc-buffer.png

The second shows the translations displayed in a tooltip. If you use rdictcc-tooltip-mode in a buffer, you’ll get such a tooltip for every word your mouse points at (after a short configurable delay).

http://www.tsdh.de/images/rdictcc-tooltip.png