#! /bin/sh
# Create user's linguistic.xcu file with current locale set ad default language
UserInstallDir=$1
SystemInstallDir=$2

setup_xml=$UserInstallDir/user/registry/data/org/openoffice/Office/Linguistic.xcu
system_xml=$SystemInstallDir/share/registry/schema/org/openoffice/Office/Linguistic.xcs

      lang="$LC_ALL"
      if [ -z "$lang" ]; then
	lang="$LANG"
      fi
      lang=$(echo "$lang" | sed -n "s/\([a-z]*_[A-Z]*\).*/\1/p")
      if [ -z "$lang" ]; then
	lang=en_US
      fi
      grep -v '</oor:component-schema>' $system_xml | sed -e 's/oor:component-schema/oor:component-data/g' > $setup_xml
      cat <<EOF >> $setup_xml
 <node oor:name="General">
  <prop oor:name="DefaultLocale" oor:type="xs:string">
   <value>${lang/_/-}</value>
  </prop>
 </node>
EOF
echo '</oor:component-data>' >> $setup_xml
