[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: got OOo in french !



On Thu, May 16, 2002 at 12:08:58PM +0200, Gerfried Fuchs wrote:
> * Martin Quinson <Martin.Quinson@tuxfamily.org> [2002-05-16 11:22]:
> > # Fix some variable to make the paths shorter in the rest
> > oohome="$HOME/.openoffice"
> > lingfile="$oohome/user/config/registry/instance/org/openoffice/Office/Linguistic.xml"
> > setupfile="$oohome/user/config/registry/instance/org/openoffice/Setup.xml"
> 
>  That is a good starting point to make it easier to extend the script
> from hardcoded oohome to parsed ~/.sversionrc oohome :)

ok, i did change that too.

now, the script search for the installed directory in .sversionrc, (or
/etc/openoffice/..... if not found). 

It also detect the broken situation when the user removed the install dir
without updating the .sversionrc and gives an (hopefully) helpfull error msg.

> > # Search the right locale
> > if [ -e $oohome/lang.debian ] ; then
> >   OLDLOCALE=`cat $oohome/lang.debian`
> > else
> >   OLDLOCALE=en-US
> > fi
> > LOCALE=$LC_ALL
> > if [ -z $LOCALE ] ; then LOCALE="$LC_MESSAGES"; fi
> > if [ -z $LOCALE ] ; then LOCALE="$LANG"; fi
> > if [ -z $LOCALE ] ; then LOCALE="en-US"; fi
> 
>  ... uhm, en-US?  Isn't that broken and should be en_US instead?

Yes it's broken, but it's what you find in the 00 files...

> > unset SESSION_MANAGER
> 
>  Nice boy ,-)

I use gnome myself ;)

> > ~/.openoffice/soffice
> 
>  That should be changed to
> $oohome/soffice
>  too.  Don't know if you missed it somewhere else, too.

Fixed.


That's it. this time, people, wait a bit before finding a new better idea. I
*really* have to work for the real life ;)

Bye, Mt;

-- 
- Votre profession ?
- Je travaille dans une usine de cycles. Je suis cadre.
          --- Désolé
#!/bin/sh
#
# Wrapper script for openoffice
#
# (C) Peter 'Nidd' Novodvorsky, 2001.
# (C) Martin 'empty' Quinson, 2002.

# This program is free software; 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.                                     
#                                                                             
# You should have received a copy of the GNU General Public License            
# along with this program; if not, write to the Free Software                  
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA      

# this string should be exactly as in ~/.sversion
OOVERSION="OpenOffice.org 1.0"

##
## where does OO live for this user ?
##
OOHOME=""
if [ -e ~/.sversionrc ] && grep -q "$OOVERSION" ~/.sversionrc ; then
  # already installed for this user (warning, .sversionrc is DOS encoded)
  OOHOME=`grep "$OOVERSION" ~/.sversionrc| \
          sed "s|^$OOVERSION=file://||"  | \
	  sed -e 's/[[:blank:]]//g' -e 's/
//'`
  if [ ! -e $OOHOME ] ; then
    echo "I'm confused because I can't find OpenOffice's user files."
    echo "Your ~/.sversionrc file tells they should be under $OOHOME,"
    echo "but they are not. Please fix the situation manually."
    echo "You may want to edit ~/.sversionrc to indicate where is OO"
    echo "installed, or remove it if you did remove your installation"
    echo "directory manually (you bad one)."
    exit 1
  fi
fi
if [ -z $OOHOME ] ; then
  if [ -e /etc/openoffice/autoresponse.conf ] && \
    grep -q DESTINATIONPATH /etc/openoffice/autoresponse.conf ; then
    # first install
    OOHOME=`grep DESTINATIONPATH /etc/openoffice/autoresponse.conf | \
           sed -e 's/DESTINATIONPATH=//' -e "s|<home>|$HOME|"`
  else
    echo "Damnit! I can't find OpenOffice's user files. Did you break"
    echo "the /etc/openoffice/autoresponse.conf file manually ?"
    echo "This file should contain DESTINATIONPATH"
    exit 1
  fi
fi

##
## install OO for this user if needed
##
if [ ! -d $OOHOME ]; then
  /usr/lib/openoffice/program/setup -R:/etc/openoffice/autoresponse.conf
fi 

##
## Change the config files to conform to current locale used
##

# Fix some variable to make the paths shorter in the rest
LINGFILE="$OOHOME/user/config/registry/instance/org/openoffice/Office/Linguistic.xml"
SETUPFILE="$OOHOME/user/config/registry/instance/org/openoffice/Setup.xml"


# Search the right locale
if [ -e $LINGFILE ] ; then
  OLDLOCALE=`grep DefaultLocale $LINGFILE|sed 's/<[^>]*>//g'|sed 's/[[:blank:]]//g'`
else
  OLDLOCALE=en-US
fi
LOCALE=$LC_ALL
if [ -z $LOCALE ] ; then LOCALE="$LC_MESSAGES"; fi
if [ -z $LOCALE ] ; then LOCALE="$LANG"; fi
if [ -z $LOCALE ] ; then LOCALE="en-US"; fi
if [ $LOCALE != $OLDLOCALE ] ; then 

  # Change instdb.ins
  cp $OOHOME/instdb.ins $OOHOME/instdb.ins.$OLDLOCALE
  sed "s/>$OLDLOCALE</>$LOCALE</" $OOHOME/instdb.ins.$OLDLOCALE > $OOHOME/instdb.ins
  
  # Create Linguistic.xml if don't exists
  if [ ! -e $LINGFILE.$OLDLOCALE ] ; then
    # get a default one, and change en-US to OLDLOCALE inside. I guess this is a noop, but I'm not sure
    sed "s/>en-US</>$OLDLOCALE</" \
      < /usr/lib/openoffice/share/config/registry/instance/org/openoffice/Office/Linguistic.xml \
      > $LINGFILE.$OLDLOCALE
  fi
  
  # change Linguistic.xml
  sed "s/>$OLDLOCALE</>$LOCALE</" $LINGFILE.$OLDLOCALE > $LINGFILE

  # Change Setup.xml
  if grep -q '<ooLocale cfg:type' $SETUPFILE ; then 
    cp $SETUPFILE $SETUPFILE.$OLDLOCALE
    sed "s/>$OLDLOCALE</>$LOCALE</" $SETUPFILE.$OLDLOCALE > $SETUPFILE
  else # ooLocale entry does not exists in Setup.xml
    cp $SETUPFILE $SETUPFILE.tmp
     
    cat $SETUPFILE.tmp | \
      perl -e "while (<>) { /<Office>/ && print \"<L10N>\n<ooLocale cfg:type=\\\"string\\\">$LOCALE</ooLocale>\n</L10N>\n\";print $_;}" > \
      $SETUPFILE 
    # this perl command is to add a <L10N> section if it does not exists.
    # On my machine, it produce the following patch:
    
    # <Setup state="modified" cfg:package="org.openoffice" xmlns="http://openoffice.org/2000/registry/components/Setup"; xmlns:cfg="http://openoffice.org/2000/registry/instance"; xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance";>
    #+ <L10N>
    #+  <ooLocale cfg:type="string">fr_FR@euro</ooLocale>
    #+ </L10N>
    #  <Office>
   
    rm $SETUPFILE.tmp
  fi # change Setup.xml
  
fi # LOCALE != OLDLOCALE

##
## Forbid the gnome session manager to mess up here
##  (it kills OO right after startup)
unset SESSION_MANAGER

##
## That's it. Launch the beast
##
$OOHOME/soffice

Reply to: