Author: pb Date: 2005-12-28 12:02:51 +0000 (Wed, 28 Dec 2005) New Revision: 1074
Added: glibc-package/trunk/debian/local/manpages/po4a.cfg glibc-package/trunk/debian/local/manpages/validlocale.8 glibc-package/trunk/debian/local/usr_sbin/validlocale Modified: glibc-package/trunk/debian/local/manpages/Makefile Log: import some files for validlocale Modified: glibc-package/trunk/debian/local/manpages/Makefile =================================================================== --- glibc-package/trunk/debian/local/manpages/Makefile 2005-12-27 14:07:41 UTC (rev 1073) +++ glibc-package/trunk/debian/local/manpages/Makefile 2005-12-28 12:02:51 UTC (rev 1074) @@ -1,10 +1,20 @@ #! /usr/bin/make -f +DIRS := de es fr id pl pt_BR + SGML_MAN = locale-gen.8 -all: $(patsubst %.pod,%.1,$(wildcard *.pod)) $(SGML_MAN) +all: $(patsubst %.pod,%.1,$(wildcard *.pod)) $(SGML_MAN) po4a-man %.1: %.pod pod2man --center="Debian GNU/Linux" --release="woody" $< > $@ locale-gen.8: locale-gen.8.sgml docbook-to-man $< > $@ + +po4a-man: + po4a -q po4a.cfg + +clean: + po4a -q po4a.cfg + $(foreach dir, $(DIRS), rm -rf $(dir)/*.8) + rm -f po/*~ Added: glibc-package/trunk/debian/local/manpages/po4a.cfg =================================================================== --- glibc-package/trunk/debian/local/manpages/po4a.cfg 2005-12-27 14:07:41 UTC (rev 1073) +++ glibc-package/trunk/debian/local/manpages/po4a.cfg 2005-12-28 12:02:51 UTC (rev 1074) @@ -0,0 +1,7 @@ +[po4a_paths] po/man.pot de:po/de.po es:po/es.po id:po/id.po \ + fr:po/fr.po pl:po/pl.po pt_BR:po/pt_BR.po + +[type: man] validlocale.8 es:es/validlocale.es.8 \ + id:id/validlocale.id.8 add_id:id/addendum.id fr:fr/validlocale.fr.8 \ + add_fr:fr/addendum.fr pl:pl/validlocale.pl.8 \ + pt_BR:pt_BR/validlocale.pt_BR.8 Added: glibc-package/trunk/debian/local/manpages/validlocale.8 =================================================================== --- glibc-package/trunk/debian/local/manpages/validlocale.8 2005-12-27 14:07:41 UTC (rev 1073) +++ glibc-package/trunk/debian/local/manpages/validlocale.8 2005-12-28 12:02:51 UTC (rev 1074) @@ -0,0 +1,49 @@ +.TH "validlocale" "8" "0.1" "Petter Reinholdtsen" "" +.SH "NAME" +.LP +validlocale \- Test if a given locale is available +.SH "SYNTAX" +.LP +validlocale <\fIlocale\fP> +.SH "DESCRIPTION" +.LP +Test if the locale given as argument is a valid locale. If it +isn't, print on stdout the string to add to /etc/locale.gen to make +locale\-gen generate the locale (if it exists at all). +.SH "FILES" +.LP +\fI/usr/sbin/validlocale\fP +.br +\fI/usr/share/i18n/SUPPORTED\fP +.SH "ENVIRONMENT VARIABLES" +.LP +.TP +\fBDEFAULTCHARSET\fP +Which charset to assume if the given locale is missing from the +list of supported locales. +.SH "EXAMPLES" +.LP +If you give a valid locale as parameter, it outputs a string +specifying this on stderr: +.LP +.IP +% validlocale C +.br +locale 'C' valid and available +.LP +When given a invalid (not generated or just nonexistent), it +outputs a string on stderr telling that this is an invalid locale, and a string to stdout with the string to add to /etc/locale.gen +to have this locale generated: +.LP +.IP +% validlocale [EMAIL PROTECTED] +.br +locale '[EMAIL PROTECTED]' not available +.br [EMAIL PROTECTED] ISO\-8859\-15 +.SH "AUTHORS" +.LP +Petter Reinholdtsen <[EMAIL PROTECTED]> +.SH "SEE ALSO" +.LP +locale\-gen(8), localedef(1), locale(1) Added: glibc-package/trunk/debian/local/usr_sbin/validlocale =================================================================== --- glibc-package/trunk/debian/local/usr_sbin/validlocale 2005-12-27 14:07:41 UTC (rev 1073) +++ glibc-package/trunk/debian/local/usr_sbin/validlocale 2005-12-28 12:02:51 UTC (rev 1074) @@ -0,0 +1,75 @@ +#!/usr/bin/perl -w +# +# Author: Petter Reinholdtsen <[EMAIL PROTECTED]> +# Date: 2002-02-23 +# +# Test if the locale given as argument is a valid locale. If it +# is not, print on stdout the string to add to /etc/locale.gen to make +# locale-gen generate the locale (if it exists at all). + +use POSIX qw(setlocale LC_ALL); + +my $debug = 0; + +my $defaultcharset = $ENV{"DEFAULTCHARSET"} || "ISO-8859-1"; + +my $supportedlist = "/usr/share/i18n/SUPPORTED"; + +unless (defined $ARGV[0]) { + usage(); + exit 1; +} + +my $LANG = $ARGV[0]; + +my $loc = setlocale(LC_ALL, $LANG); +if ( ! $loc) { + print STDERR "locale '$LANG' not available\n"; + + my ($locale) = $LANG =~ m/^([EMAIL PROTECTED])/; + my ($charset) = $LANG =~ m/^[^.]+\.([EMAIL PROTECTED])/; + my ($modifier) = $LANG =~ m/(@.+)$/; + + $modifier = "" unless defined $modifier; + + # Hm, if charset is missing, how to we pick the correct one to + # use? Fetching the value from /usr/share/i18n/SUPPORTED should + # work on Debian. + my $codeset = ""; + if (defined $charset) { + $codeset = '.' . $charset; + } else { + $charset = get_default_charset("$locale$modifier"); + } + + # print "L: $locale C: $charset M: $modifier\n"; + print "$locale$codeset$modifier $charset\n"; + + exit 1; +} else { + print STDERR "locale '$LANG' valid and available\n"; + exit 0; +} + +sub usage { + print "Usage: $0 <locale>\n" +} + +sub get_default_charset { + my ($locale) = @_; + my ($l, $c); + open(SUPPORTED, "< $supportedlist") || die "Unable to open $supportedlist"; + while (<SUPPORTED>) { + chomp; + ($l, $c) = split(/\s+/); + print "Checking '$l' '$c' != '$locale'\n" if $debug; + last if ($l eq $locale); + } + close(SUPPORTED); + + if ($l eq $locale) { + return $c; + } else { + return $defaultcharset; + } +} Property changes on: glibc-package/trunk/debian/local/usr_sbin/validlocale ___________________________________________________________________ Name: svn:executable + * -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]