Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Sharing OOo dictionaries with Firefox and Thunderbird
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Guenther Brunthaler
Apprentice
Apprentice


Joined: 22 Jul 2006
Posts: 217
Location: Vienna

PostPosted: Thu Apr 24, 2008 1:49 am    Post subject: HOWTO: Sharing OOo dictionaries with Firefox and Thunderbird Reply with quote

Hi all,

Ever wondered how to share your already-installed OpenOffice.org spelling dictionaries with Mozilla Thunderbird and Firefox without downloading/installing a second set of dictionaries, thus saving megabytes of space?

Then read on!

I wrote a script which creates or updates symlinks from all the installed OpenOffice.org spelling dictionaries in such a way that those dictionaries are accessible from the builtin FF/TB dictionary selection dialogs.

That is, no more downloading and installing of separate extensions for that purpose.

To be more precise, OOo uses the myspell-ebuilds such as app-dicts/myspell-en as its spelling dictionaries, so my script locates all installed myspell-dictionaries and creates/updates any required symlinks. And after you uninstalled some of the dictionaries, my script will remove the dead leftover symlinks.

Anyway, usage is easy and straightforward:

  • The following commands must be run as root, so do a
    Code:
    su -
    if necessary.
  • Save the script under some name (I suggest "/usr/local/sbin/myspell-sync")
  • Make it executable:
    Code:
    # chmod +x /usr/local/sbin/myspell-sync

  • Run it!
    Code:
    myspell-sync



That's all. Except that re-installing FF/TB will delete the symlinks my script has created, and so you will have to re-run it after each update of FF/TB.

Anyway, it's safe to run the script at any time, so it won't hurt if you run it each time you suspect that the list of dictionaries provided by the FF/TB selection dialogs might be incomplete or outdated.

Note that the script makes the installed OOo/myspell dictionaries available to all the users of the local machine, that is it no longer necessary to install the dictionaries on a per-user basis (which helps avoiding to waste space). Note that this will not stop your users from installing additional dictionaries on their own if they absolutely want. But it will make it unnecessary in most cases.

However, here is an important DISCLAIMER: This script has only been tested for the normal sourcecode-builds of OOo, TB and FF. That is, not for the -bin ebuilds. I do not use any -bin ebuilds on my machines. The -bin versions might therefore be installed into different directories, and thus you might have to change the "/usr/lib/mozilla-firefox/dictionaries" and "/usr/lib/mozilla-thunderbird/dictionaries"-paths in the script. But there is no danger - my script checks all the paths to exist before it uses them.

And finally - here is the script:

Code:
#! /bin/sh
# Symlinks installed myspell dictionaries
# for use with Mozilla Firefox and Thunderbird.
# Can also be used to update existing symlinks.
# Will also detect and remove outdated symlinks.
#
# Written in 2008 by Guenther Brunthaler


# Where to find the installed myspell dictionaries.
MYSPELLDICTS=/usr/share/myspell


die() {
   echo "ERROR: $*" >& 2
   exit 1
}


run() {
   "$@" && return
   die "Could not execute >>>$*<<<: return code ${?}!"
}


check_symlink() {
   local T RM
   T=`readlink --canonicalize "$1"`
   if test -f "$T"; then
      # Remove symlinks to be recreated.
      test x"${T#$MYSPELLDICTS/}" != x"$T" && RM=1
   else
      # Remove outdated symlinks.
      RM=1
   fi
   test -z "$RM" && return
   run rm "$1"
}


createlinks() {
   local D N N2 P X COLL BAD CI
   D=$2
   N=${1##*/}
   P=${1%/$N}
   N=${N%.*}
   # Collect extensions to be symlinked.
   set --
   for X in dic aff; do
      test -f "$P/$N.$X" && set -- "$@" "$X"
   done
   # Mozilla expects ll-CC* names instead of ll_CC* names.
   N2=`echo "$N" | sed -e 's/_/-/'`
   # Collision avoidance.
   CI=1
   while true; do
      BAD=
      for X in "$@"; do
         if test -e "$D/$N2$COLL.$X"; then
            BAD=1
            break
         fi
      done
      test -z "$BAD" && break
      COLL=$CI
      CI=`expr $CI + 1`
      test $COLL = 1 && COLL=
      COLL=_myspell$COLL
   done
   for X in "$@"; do
      run ln -s "$P/$N.$X" "$D/$N2$COLL.$X"
   done
}


run test -d "$MYSPELLDICTS"
# Add more paths to obtain symlinked copies of the
# myspell dictionaries in the lines below if you want.
for D in \
   /usr/lib/mozilla-firefox/dictionaries \
   /usr/lib/mozilla-thunderbird/dictionaries \
; do
   if test -d "$D"; then
      echo "Symlinking dictionaries into $D..."
      for L in "$D"/*; do
         test -L "$L" && check_symlink "$L"
      done
      # Match only dictionaries, not thesauri or hyph* files.
      for DICT in "$MYSPELLDICTS"/[a-z][a-z]_[A-Z][A-Z]*.dic; do
         test -f "$DICT" && createlinks "$DICT" "$D"
      done
   fi
done


Have fun!
Back to top
View user's profile Send private message
peteblack
n00b
n00b


Joined: 28 Aug 2005
Posts: 26

PostPosted: Mon May 20, 2013 9:51 pm    Post subject: Thanks! Reply with quote

Just came a cross this and even though this is a few years old it worked like a charm. Strange, I can't be the only one without myspell dictionaries in firefox/thunderbird anymore?

For the *-bins the dictionary path is under /opt, that is:

Code:

--- /usr/local/sbin/myspell-sync.org    2013-05-20 23:49:27.024146278 +0200
+++ /usr/local/sbin/myspell-sync        2013-05-20 23:38:16.004535177 +0200
@@ -77,8 +77,8 @@
 # Add more paths to obtain symlinked copies of the
 # myspell dictionaries in the lines below if you want.
 for D in \
-   /usr/lib/mozilla-firefox/dictionaries \
-   /usr/lib/mozilla-thunderbird/dictionaries \
+   /opt/firefox/dictionaries \
+   /opt/thunderbird/dictionaries \
 ; do
    if test -d "$D"; then
       echo "Symlinking dictionaries into $D..."


Thanks Guenther!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum