sporkstorms.org
sporkstorms.org miscellaneous code bits software photos
don't touch that dial!

Cocoa/Perl CEDICT interface

This is an old version of the software. Please check out CocoaCEDICT instead.

CocoaPerlCEDICT is an OS X Cocoa interface to the CEDICT Chinese English Dictionary (Mandarin/Putonghua).

This is the shiny new version. If for whatever reason you want the old interface to Lingua::ZH::CEDICT, go to the old CocoaPerlCEDICT page.

about

CocoaPerlCEDICT provides an interface to a Chinese-English dictionary. It supports looking up words by their English definition, traditional Chinese text, simplified Chinese text, and Pinyin pronounciation (optionally filtering only those with an exact tone match).

The layout of its interface is partly based on that of OriDict, and the application icon from it is used.

notable features:

  • Search by English, Pinyin, Pinyin with tone, traditional Chinese, and simplified Chinese
  • Filter results: "begins with", "ends with", "exact match", "partial match"
  • Optionally show tone marks instead of digits. Example: pin1 yin1 becomes pīn yīn
  • Separate font faces and sizes for Chinese and Roman (English, Pinyin)
  • Convenient font resizing with sliders on the main window
  • Easy modification of program behavior. Just edit the Perl modules within the application bundle. No need to recompile.
  • Resize and rearrange the columns. The application remembers these settings and restores them each time you run it
  • Control-click an entry to bring up a copy menu. This allows you to quickly and easily copy any part of the definition, or the entire definition, to the system's pasteboard.
    The first item in the menu is always the section of the definition you clicked on.

This application is a testiment to the virtues of rapid development using CamelBones. The original version was thrown together in under an hour! This new version (with many more features) took an additional few hours, which is still quite impressive when compared to how long this application would take to write in Objective C.

Note: The input from the search field is used in a quoted regular expression (qr{search text}). Special characters are not escaped and quotemeta is not called.
I use this as a feature.
Be sure to change it if this will be a problem for you - but be careful if you wish to use quotemeta() and expect Chinese text for input.

screenshot

CocoaPerlCEDICT

download

application version 2.1 (0.98 MB - contains the dictionary data)
source version 2.1 (1.9 MB - contains the dictionary data)

Changes:
  • Main window now remembers its size and position between runs
  • Switched to regular sized scrollbars

Older version can be found in the code directory

requirements

  • OS X 10.3. or later

    If you want to run this program on an earlier version of OS X and are willing to put a little work into it, let me know and I'll be glad to help you get it running. I don't have a 10.2 or 10.1 installation to work with, so I will need your assistance to test it.

  • Camelbones

    To run CamelBones apps install the runtime framework.
    In case you want to write your own Cocoa/Perl applications, install the developer package instead.

  • Storable.pm Perl module

    You should already have this module installed on your system.

    If the program does not work, it may not be. An easy way to determine whether it's installed is to bring up the Terminal program and type
    perl -MStorable -e "1"
    If no errors are spit out, you're fine.

    If you find that you do not have the module installed, you'll need to install it manually. Here's a quick overview in case you've never installed Perl modules before. This may seem rather troublesome.

    • You will probably need your root account enabled. Here's how.
    • Open a terminal (Terminal in your Applications -> Utilities folder).
    • Type sudo perl -MCPAN -e "install Storable". It will ask for a password. If it said something like "sorry try again", "you aren't authorized..." or anything to that effect, continue reading. Otherwise skip to the next step.
      Try typing su, then enter the password. if it didn't spit out any errors, type perl -MCPAN -e "install Storable".
    • Answer any questions the CPAN installation gives you. Let it install any dependencies that are required.
    • All done.

additional thanks and credits

This heart of this application uses the Camel Bones framework. Camel Bones allows you to use Cocoa with Perl, and is absolutely wonderful for quickly writing GUI applications. It's written by Sherm Pendley and released as free software (under the LGPL).

The CEDICT is a Chinese/English dictionary project started by Paul Denisowski. More information and the original dictionary files can be found here.

CocoaPerlCEDICT uses a class called RowResizableTableView written by Evan Jones. It allows variable row heights within an NSTableView (he's also written a similar class for NSOutlineViews)
Check it out here

The application icon is from OriDict

The essence of, and lookup table for the MyCEDICT::Definition::pinyin_utf8() method is from the Lingua::ZH::CEDICT Perl module.

License and Copyright

CocoaPerlCEDICT is Copyright © 2004, Mark A. Stratman <mark@sporkstorms.org>

It is licensed under the GNU General Public License.
You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.