wok diff slitaz-i18n/stuff/locale-pack.functions @ rev 14908

slitaz-i18n: rewrite locale-pack.functions; slitaz-configs: now generate openbox desktop menu using po files; locale-*: update using new locale-pack.functions (FIXME: post_remove)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Aug 03 17:37:48 2013 +0300 (2013-08-03)
parents 919b102812ab
children 1c56350ea155
line diff
     1.1 --- a/slitaz-i18n/stuff/locale-pack.functions	Sun Jun 02 12:09:39 2013 +0000
     1.2 +++ b/slitaz-i18n/stuff/locale-pack.functions	Sat Aug 03 17:37:48 2013 +0300
     1.3 @@ -1,71 +1,61 @@
     1.4 -#!/bin/sh
     1.5 +get_locale()
     1.6 +{
     1.7 +	[ "x$CHARMAP" == x ] && CHARMAP=UTF-8
     1.8  
     1.9 -# Standard directories having translated files.
    1.10 -mk_locale_dir()
    1.11 -{
    1.12 -	mkdir -p \
    1.13 -		$fs/usr/share/locale/$LOCALE \
    1.14 -		$fs/etc/xdg/openbox
    1.15 -}
    1.16 -
    1.17 -# Get translated files from SliTaz sub projects: configs & tools.
    1.18 -get_slitaz_messages()
    1.19 -{
    1.20 -	configs=$WOK/slitaz-configs/source
    1.21 -	openbox=$configs/slitaz-configs-*/rootfs/etc/xdg/openbox
    1.22 -	#tools=$WOK/slitaz-tools/source
    1.23 -
    1.24 -	# Make tazwok compatible with this.
    1.25 -	if [ ! -x /usr/bin/cook ]; then
    1.26 -		[ -d $configs ] || tazwok get-src slitaz-configs --target=$configs
    1.27 -		#[ -d $tools ] || tazwok get-src slitaz-tools --target=$tools
    1.28 +	# Get translated Openbox menu from SliTaz sub project slitaz-configs
    1.29 +	obmenu=$WOK/slitaz-configs/install/etc/xdg/openbox/menu.$LOCALE.xml
    1.30 +	if [ -f $obmenu ]; then
    1.31 +		mkdir -p $fs/etc/xdg/openbox
    1.32 +		echo "* Found $LOCALE translations for: openbox menu"
    1.33 +		cp $obmenu $fs/etc/xdg/openbox
    1.34  	fi
    1.35  
    1.36 -	[ ! -d $configs ] && echo "ERROR: missing source slitaz-configs" && exit 1
    1.37 -	#[ ! -d $tools ] && echo "ERROR: missing source slitaz-tools" && exit 1
    1.38 -
    1.39 -	if [ -f $openbox/menu.${LOCALE}.xml ]; then
    1.40 -		echo "* Found $LOCALE locale for: openbox menu"
    1.41 -		cp $openbox/menu.${LOCALE}.xml $fs/etc/xdg/openbox
    1.42 -	fi
    1.43 -	
    1.44 -	# Tools messages will be replace in time by POT files.
    1.45 -	#
    1.46 -	# NOTE: All po files are now include into slitaz-tools (easy for update)
    1.47 -	#
    1.48 -	#if [ -d $tools/slitaz-tools-*/messages/$LOCALE ]; then
    1.49 -		#echo "* Found $LOCALE locale for: slitaz-tools"
    1.50 -		#cp -a $tools/slitaz-tools-*/messages/$LOCALE \
    1.51 -			#$fs/usr/share/slitaz/messages
    1.52 -	#fi
    1.53 -	
    1.54 -	#if [ -d $tools/slitaz-tools-*/po/mo/$LOCALE ]; then
    1.55 -		#for app in $(ls $tools/slitaz-tools-*/po/mo/$LOCALE)
    1.56 -		#do
    1.57 -			#echo "* Found $LOCALE locale for: ${app%.mo}"
    1.58 -			#cp -a $tools/slitaz-tools-*/po/mo/$LOCALE/$app \
    1.59 -				#$fs/usr/share/locale/$LOCALE
    1.60 -		#done
    1.61 -	#fi
    1.62 -}
    1.63 -
    1.64 -# Get the core packages messages.
    1.65 -get_core_messages()
    1.66 -{
    1.67 -	for i in $CORE_PKGS
    1.68 -	do
    1.69 -		if [ -d $WOK/$i/install/usr/share/locale/$LOCALE ]; then
    1.70 -			echo "* Found $LOCALE locale for: $i"
    1.71 -			cp -a $WOK/$i/install/usr/share/locale/$LOCALE \
    1.72 -				$fs/usr/share/locale
    1.73 +	# Get the core packages messages.
    1.74 +	mkdir -p $fs/usr/share/locale/$LOCALE
    1.75 +	for app in $CORE_PKGS; do
    1.76 +		app_locale=$WOK/$app/install/usr/share/locale/$LOCALE
    1.77 +		if [ -d $app_locale ]; then
    1.78 +			echo "* Found $LOCALE translations for: $app"
    1.79 +			cp -a $app_locale $fs/usr/share/locale
    1.80  		fi
    1.81  	done
    1.82 +
    1.83 +	# List of available locales
    1.84 +	cd $WOK/glibc/install/usr/share/i18n/locales
    1.85 +	locales=$(ls -1 | sed -n '/^'$LOCALE'$/p; /^'$LOCALE'_.*/p' | sed '/translit/d')
    1.86 +	[ "x$LOCALEDEF" != x ] && locales=$LOCALEDEF
    1.87 +
    1.88 +	# Get X11 locale
    1.89 +	for def in $locales; do
    1.90 +		x11_locale=$WOK/xorg-libX11/install/usr/share/X11/locale/$def.$CHARMAP
    1.91 +		if [ -d $x11_locale ]; then
    1.92 +			echo "* Found $def.$CHARMAP locale for: X11"
    1.93 +			mkdir -p $fs/usr/share/X11/locale
    1.94 +			cp -a $x11_locale $fs/usr/share/X11/locale
    1.95 +		fi
    1.96 +	done
    1.97 +
    1.98 +	# Pregenerate locale file so we dont need glibc-locale as dep.
    1.99 +	for def in $locales; do
   1.100 +		echo "* Generate $def locale definition"
   1.101 +		mkdir -p $fs/usr/lib/locale
   1.102 +		localedef -i $def -c -f $CHARMAP $fs/usr/lib/locale/$def
   1.103 +	done
   1.104 +
   1.105 +	# Get timezones
   1.106 +	countries=$(echo $locales | \
   1.107 +		sed 's|@[^ ]*||g; s|[^ _]*_||g' | tr ' ' '\n' | sort -u)
   1.108 +	echo "* Copy timezone info for countries: "$countries
   1.109 +	locations=''
   1.110 +	for country in $countries; do
   1.111 +		location=$(grep '^'$country \
   1.112 +			$WOK/glibc/install/usr/share/zoneinfo/zone.tab | awk '{ print $3}')
   1.113 +		locations="$locations $location"
   1.114 +	done
   1.115 +	for location in $locations; do
   1.116 +		for tz in $location posix/$location right/$location; do
   1.117 +			install -Dm644 /usr/share/zoneinfo/$tz \
   1.118 +						$fs/usr/share/zoneinfo/$tz
   1.119 +		done
   1.120 +	done
   1.121  }
   1.122 -
   1.123 -# Get X11 locale
   1.124 -get_x11_locale()
   1.125 -{
   1.126 -	mkdir -p $fs/usr/share/X11/locale
   1.127 -	cp -a $WOK/xorg-libX11/install/usr/share/X11/locale/$LOCALEDEF.$CHARMAP \
   1.128 -		$fs/usr/share/X11/locale
   1.129 -}