#!/bin/sh # # Copyright (C) 2008 Nokia Corporation. # Licensed under GPL version 2 # # Generate locale definition files under $HOME/.scratchbox2/ in extracted # form. We need to do this because otherwise it is impossible to map # locales under sb2 to correct target using environment variable # $LOCPATH. This script can be used to generate locales for targets # and tools. # # For target locales the generated files are placed under: # $HOME/.scratchbox2/$sbox_target/locales # and for tools the place is: # $HOME/.scratchbox2//locales. # # $LOCPATH is the only way to change path of locale files when using # glibc (other systems use $NLSPATH but we don't need to do this extraction # there). Problem is that when $LOCPATH is defined, glibc doesn't want # to read file named '$LOCPATH/locale-archive' but it assumes that files # under $LOCPATH are in extracted form. # # This is only needed when we are running binaries without cpu transparency # e.g native binaries. # prog="$0" progbase=`basename $0` generate_localization_files() { local rootdir local gendir local force rootdir=$1 gendir=$2 force=$3 if [ -d $gendir ]; then if [ $force -eq 0 ]; then return fi fi # # If there is no locale-archive in target root, we don't # need to generate anything. # if [ ! -f $rootdir/usr/lib/locale/locale-archive ]; then return fi # does localedef exist? if [ ! -x $rootdir/usr/bin/localedef ]; then # nothing to do return fi # list currently archived locales archived_locales=`$rootdir/usr/bin/localedef --list-archive \ --prefix $rootdir` if [ -z "$archived_locales" ]; then return fi echo "Generating locales under '$gendir'" /bin/mkdir -p $gendir > /dev/null 2>&1 # # Now we force localedef to use our target_root as # root for all locale operations. # I18NPATH=$rootdir/usr/share/i18n; export I18NPATH LOCPATH=$rootdir/usr/lib/locale; export LOCPATH # # Find out supported variations for a locale and generate # the files. We generate only UTF-8 versions of locales. # for l in $archived_locales; do # strip off anything that is not language name loc=`echo $l | sed 's/\..*$//'` echo -n "generating locale $loc ..." $rootdir/usr/bin/localedef \ --no-archive \ -f UTF-8 \ -c \ -i $loc \ $gendir/$loc > /dev/null 2>&1 echo " done" done unset I18NPATH unset LOCPATH } usage() { cat <