diff options
author | 2006-04-17 08:10:24 +0000 | |
---|---|---|
committer | 2006-04-17 08:10:24 +0000 | |
commit | a32f2a4c80b17ecd5bb199f630daba36b552a134 (patch) | |
tree | 574971bb19a64dbc14c14c9a523059608efac419 | |
download | locale-gen-a32f2a4c80b17ecd5bb199f630daba36b552a134.tar.gz locale-gen-a32f2a4c80b17ecd5bb199f630daba36b552a134.tar.bz2 locale-gen-a32f2a4c80b17ecd5bb199f630daba36b552a134.zip |
new locale handling based upon Debians work
-rwxr-xr-x | locale-gen | 156 | ||||
-rw-r--r-- | locale-gen.8 | 101 | ||||
-rw-r--r-- | locale.gen | 31 | ||||
-rw-r--r-- | locale.gen.5 | 41 |
4 files changed, 329 insertions, 0 deletions
diff --git a/locale-gen b/locale-gen new file mode 100755 index 0000000..dd5cf3c --- /dev/null +++ b/locale-gen @@ -0,0 +1,156 @@ +#!/bin/bash + +# +# Based upon Debian's locale-gen, fetched from glibc_2.3.6-7.diff.gz +# + +unset POSIXLY_CORRECT +umask 022 + +argv0=${0##*/} +source /etc/init.d/functions.sh || { + echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 + exit 1 +} + +show_usage() { + cat <<-EOF + Usage: ${HILITE}${argv0}${NORMAL} ${GOOD}[options]${NORMAL} + + Generate locales based upon the config file /etc/locale.gen. + + ${HILITE}Options:${NORMAL} + ${GOOD}-k, --keep${NORMAL} Don't nuke existing locales + ${GOOD}-d, --destdir <dir>${NORMAL} Use locale data in specified DESTDIR tree + ${GOOD}-c, --config <config>${NORMAL} Use specified config instead of default locale.gen + ${GOOD}-l, --list${NORMAL} List all the locales to be generated + ${GOOD}-q, --quiet${NORMAL} Only show errors + ${GOOD}-V, --version${NORMAL} Meaningless version information + ${GOOD}-h, --help${NORMAL} Show this help cruft + + For more info, see the ${HILITE}locale-gen${NORMAL}(1) and ${HILITE}locale.gen${NORMAL}(8) manpages. + EOF + [[ -z $@ ]] && exit 0 + echo "" + eerror "Unknown option '$1'" + exit 1 +} +show_version() { + local cvsver="$Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/locale/locale-gen,v 1.1 2006/04/17 08:10:24 vapier Exp $" + cvsver=${cvsver##*locale-gen-} + echo "locale-gen-${cvsver%%,v *}" + exit 0 +} + + + +KEEP="" +DESTDIR="" +CONFIG="" +JUST_LIST="" +QUIET=0 +while [[ -n $1 ]] ; do + case $1 in + -k|--keep|--keep-existing) KEEP=$1;; + -d|--destdir) shift; DESTDIR=$1;; + -c|--config) shift; CONFIG=$1;; + -l|--list) JUST_LIST=$1;; + -q|--quiet) ((++QUIET));; + -V|--version) show_version;; + -h|--help) show_usage;; + *) show_usage $1;; + esac + shift +done + +ROOT=${ROOT:-/} +[[ ${ROOT} != */ ]] && ROOT="${ROOT}/" +if [[ -n ${DESTDIR} ]] && [[ ${ROOT} != "/" ]] ; then + eerror "DESTDIR and ROOT are mutually exclusive options" + exit 1 +fi +if [[ ${ROOT} != "/" ]] ; then + einfo "Using locale.gen from ROOT ${ROOT}etc/" +fi +if [[ -n ${DESTDIR} ]] ; then + einfo "Building locales in DESTDIR ${DESTDIR}" +else + DESTDIR=${ROOT} +fi + +# XXX: should fix this ... +if [[ ${DESTDIR} != "/" || ${ROOT} != "/" ]] ; then + eerror "Sorry, but DESTDIR/ROOT support is incomplete at this time." + exit 0 +fi + +LOCALEGEN=${CONFIG:-${ROOT}etc/locale.gen} +LOCALES=${DESTDIR}usr/share/i18n/locales +CHARMAPS=${DESTDIR}usr/share/i18n/charmaps +SUPPORTED=${DESTDIR}usr/share/i18n/SUPPORTED +ALIAS=${DESTDIR}usr/share/locale/locale.alias +LOCALEDIR=${DESTDIR}$(localedef --help | sed -n -e '/locale path/{s|.* : ||;s|:.*||;p}') + + + +mkdir -p "${LOCALEDIR}" +if [[ -z ${KEEP} ]] ; then + # Remove all old locale dir and locale-archive before generating new + # locale data. + rm -rf "${LOCALEDIR}"/* || true +fi + + + +[[ -s ${LOCALEGEN} ]] || exit 0 + +[[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] && \ +einfo "Generating locales (this might take a while)" + +ret=0 +while read locale charmap ; do + + # XXX: if we wanted to, we could check existence of + # ${LOCALES}/${locale} and ${CHARMAPS}/${charmap} + # this would fail for things like "en_US.UTF8", but + # in that case we could fall back to checking the + # SUPPORTED file ... then again, the localedef + # below will abort nicely for us ... + if [[ -z ${locale} || -z ${charmap} ]] ; then + eerror "Bad entry in locale.gen: '${locale} ${charmap}'; skipping" + continue + fi + + # These funky sed's are copied from the glibc localedata/Makefile + disp=$(echo ${locale} | sed 's/\([^.\@]*\).*/\1/') + disp=${disp}.${charmap} + disp=${disp}$(echo ${locale} | sed 's/\([^\@]*\)\(\@.*\)*/\2/') + + if [[ -f ${LOCALES}/${locale} ]] ; then + input=${locale} + else + input=$(echo ${locale} | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/') + fi + + if [[ -z ${JUST_LIST} ]] ; then + [[ ${QUIET} -eq 0 ]] && ebegin " Generating ${disp}" + localedef --no-archive -c \ + -i "${input}" \ + -f "${charmap}" \ + -A "${ALIAS}" \ + "${locale}" + my_ret=$? + ((ret+=my_ret)) + [[ ${QUIET} -eq 0 ]] && eend ${my_ret} + else + echo "${disp}" + fi +done < <(sed \ + -e 's:#.*::' \ + -e '/^[[:space:]]*$/d' \ + "${LOCALEGEN}") + +[[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] && \ +einfo "Generation complete" + +exit ${ret} diff --git a/locale-gen.8 b/locale-gen.8 new file mode 100644 index 0000000..0bfd6ae --- /dev/null +++ b/locale-gen.8 @@ -0,0 +1,101 @@ +.\" This -*- nroff -*- file has been generated from +.\" DocBook SGML with docbook-to-man on Debian GNU/Linux. +...\" +...\" transcript compatibility for postscript use. +...\" +...\" synopsis: .P! <file.ps> +...\" +.de P! +\\&. +.fl \" force out current output buffer +\\!%PB +\\!/showpage{}def +...\" the following is from Ken Flowers -- it prevents dictionary overflows +\\!/tempdict 200 dict def tempdict begin +.fl \" prolog +.sy cat \\$1\" bring in postscript file +...\" the following line matches the tempdict above +\\!end % tempdict % +\\!PE +\\!. +.sp \\$2u \" move below the image +.. +.de pF +.ie \\*(f1 .ds f1 \\n(.f +.el .ie \\*(f2 .ds f2 \\n(.f +.el .ie \\*(f3 .ds f3 \\n(.f +.el .ie \\*(f4 .ds f4 \\n(.f +.el .tm ? font overflow +.ft \\$1 +.. +.de fP +.ie !\\*(f4 \{\ +. ft \\*(f4 +. ds f4\" +' br \} +.el .ie !\\*(f3 \{\ +. ft \\*(f3 +. ds f3\" +' br \} +.el .ie !\\*(f2 \{\ +. ft \\*(f2 +. ds f2\" +' br \} +.el .ie !\\*(f1 \{\ +. ft \\*(f1 +. ds f1\" +' br \} +.el .tm ? font underflow +.. +.ds f1\" +.ds f2\" +.ds f3\" +.ds f4\" +'\" t +.ta 8n 16n 24n 32n 40n 48n 56n 64n 72n +.TH "LOCALE-GEN" "8" +.SH "NAME" +locale-gen \(em generates localisation files from templates +.SH "SYNOPSIS" +.PP +\fBlocale-gen\fP +.SH "DESCRIPTION" +.PP +This manual page documents briefly the +\fBlocale-gen\fP command. +.PP +By default, the locale package which provides the base support for +localisation of libc-based programs does not contain usable localisation +files for every supported language. This limitation has became necessary +because of the substantial size of such files and the large number of +languages supported by libc. As a result, Debian uses a special +mechanism where we prepare the actual localisation files on the target +host and distribute only the templates for them. +.PP +\fBlocale-gen\fP is a program that reads the file +\fB/etc/locale.gen\fP and invokes +\fBlocaledef\fP for the chosen localisation profiles. +Run \fBlocale-gen\fP after you have modified the \fB/etc/locale.gen\fP file. + + +.SH "FILES" +.PP +\fB/etc/locale.gen\fP +.PP +The main configuration file, which has a simple format: every +line that is not empty and does not begin with a # is treated as a +locale definition that is to be built. + +.SH "SEE ALSO" +.PP +localedef (1), locale (1), locale.gen (5). +.SH "AUTHOR" +.PP +This manual page was written by Eduard Bloch <blade@debian.org> for +the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GNU Free Documentation +License, Version 1.1 or any later version published by the Free +Software Foundation; with no Invariant Sections, no Front-Cover +Texts and no Back-Cover Texts. +...\" created by instant / docbook-to-man, Sat 02 Mar 2002, 16:43 diff --git a/locale.gen b/locale.gen new file mode 100644 index 0000000..09ee60e --- /dev/null +++ b/locale.gen @@ -0,0 +1,31 @@ +# /etc/locale.gen: list all of the locales you want to have on your system +# +# The format of each line: +# <locale> <charmap> +# +# Where <locale> is a locale located in /usr/share/i18n/locales/ and +# where <charmap> is a charmap located in /usr/share/i18n/charmaps/. +# +# All blank lines and lines starting with # are ignored. +# +# For the default list of supported combinations, see the file: +# /usr/share/i18n/SUPPORTED +# +# Whenever glibc is emerged, the locales listed here will be automatically +# rebuilt for you. After updating this file, you can simply run `locale-gen` +# yourself instead of re-emerging glibc. + +#en_US ISO-8859-1 +#en_US.UTF-8 UTF-8 +#ja_JP.EUC-JP EUC-JP +#ja_JP.UTF-8 UTF-8 +#ja_JP EUC-JP +#en_HK ISO-8859-1 +#en_PH ISO-8859-1 +#de_DE ISO-8859-1 +#de_DE@euro ISO-8859-15 +#es_MX ISO-8859-1 +#fa_IR UTF-8 +#fr_FR ISO-8859-1 +#fr_FR@euro ISO-8859-15 +#it_IT ISO-8859-1 diff --git a/locale.gen.5 b/locale.gen.5 new file mode 100644 index 0000000..3625018 --- /dev/null +++ b/locale.gen.5 @@ -0,0 +1,41 @@ +.\" -*- nroff -*- +.\" Copyright (C) 2002, 2005 Free Software Foundation, Inc. +.\" +.\" 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, 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. +.TH locale.gen 5 "July 2005" "Debian GNU/Linux" +.SH "NAME" +locale.gen \- Configuration file for locale-gen +.SH "DESCRIPTION" +The file \fB/etc/locale.gen\fP lists the locales that are to be generated +by the \fBlocale-gen\fP command. + +Each line is of the form: + +<locale> <charset> + +where <locale> is one of the locales given in +.B /usr/share/i18n/locales +and <charset> is one of the character sets listed in +.B /usr/share/i18n/charmaps + +The +.B locale-gen +command will generate all the locales, placing them in +\fB/usr/lib/locale\fP. + +.SH "SEE ALSO" +locale-gen(8), localedef(1), locale(1) +.SH "AUTHOR" +Alastair McKinstry <mckinstry@computer.org> |