Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Tue, Oct 25, 2005 at 07:21:59AM +0200, Marc Haber wrote: Frankly, I see no reason to keep this wrapper. If you do not want localized messages, run your scripts with LC_ALL=C. It is consistent with the way gettext is used in C programs, I tend to disagree, but that's really not important ;) and it allows gettext to be disabled completely, which might be an advantage on low memory systems. I do not know how to perform reliable memory benchmarks, but am pretty sure that disabling gettext has no noticeable impact because localized messages are not used at all with LC_ALL=C: $ strace -e open /usr/sbin/adduser --help 21 /dev/null | grep locale ... open(/usr/share/locale/fr_FR/LC_MESSAGES/adduser.mo, O_RDONLY) = -1 ENOENT (No such file or directory) open(/usr/share/locale/fr/LC_MESSAGES/adduser.mo, O_RDONLY) = 3 $ LC_ALL=C strace -e open /usr/sbin/adduser --help 21 /dev/null | grep locale $ In GNU libc, gettext() returns its argument in this case (and also when no msgstr was found), so there is no string copy. If Locale::gettext does the same (no idea whether this is true or not), gettext (with LC_ALL=C) is very similar to *gettext = sub { shift }; I have committed your changes and will upload 3.78 later today. Can you then please take a new look at the package? Sure. At the moment it did not yet reach my mirror, will look at it later. Thanks for taking care. Denis -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Sat, Oct 22, 2005 at 09:02:28PM +0200, Marc Haber wrote: Of course this comment may be improved ;) You need to call xgettext with the -c flag so that comments are inserted into PO files. that would be XGETTEXT = xgettext -c in po/Makefile, right? Done. Hmmm, I prefer adding -c after $(XGETTEXT). There is another glitch with po/Makefile: adduser-3.76/po$ touch ../adduser adduser-3.76/po$ make adduser.pot xgettext -c -L Perl -kgtx -o adduser.pot ../adduser Strings from deluser are then discarded. Patch attached. Other minor i18n problems with your package: * the gtx() function is useless and confuses xgettext gtx was named _ previously and is obviously modeled after the _ macro suggested in the gettext texinfo documentation. I'd like to keep it to be able to disable i18n for testing and debugging purposes. Unfortunately, it cannot be named _ as File::Find starts to behave very strangely when a function called _ is in the namespace. Is it possible to overload gettext with a no-op for testing purposes? If so, your changes are acceptable. I'd like to have gettext in a state where it can be disabled. Can't xgettexts confusion be remedied by replacing -k_ with -kgtx in the Makefile? I have tried this in the lastest upload to experimental, please verify. Yes, but xgettext still displays a warning. In AdduserCommon.pm, you can replace sub gtx { return gettext( join , @_); } by sub gtx { return gettext(shift): } to remove this warning. Calling gtx with a list is wrong, because only the first string is extracted into the POT file (see the attached patch, the 2nd string from deluser is not in adduser.pot). Here is a patch. I tested it, but of course it may introduce bugs, please review it carefully ;) I applied the changes, but left gtx intact. Please reconsider this suggestion. Frankly, I see no reason to keep this wrapper. If you do not want localized messages, run your scripts with LC_ALL=C. s_print (gtx(Backing up files to be removed to . $config{backup_to}. ...\n)); Doesn't this cause translation pain as well? Absolutely, I missed this one. I have changed it to s_printf (gtx(Backing up files to be removed to %s ...\n),$config{backup_to}); Thanks. Denis diff -ur adduser-3.76.old/AdduserCommon.pm adduser-3.76/AdduserCommon.pm --- adduser-3.76.old/AdduserCommon.pm 2005-10-18 16:20:00.0 +0200 +++ adduser-3.76/AdduserCommon.pm 2005-10-24 23:22:57.0 +0200 @@ -56,8 +56,8 @@ } } -sub gtx { -return gettext( join , @_); +sub gtx ($) { +return gettext(shift); } sub dief { diff -ur adduser-3.76.old/deluser adduser-3.76/deluser --- adduser-3.76.old/deluser2005-10-22 20:54:53.0 +0200 +++ adduser-3.76/deluser2005-10-24 23:32:46.0 +0200 @@ -397,7 +397,7 @@ printf gtx(Copyright (C) 2000 Roland Bauerschmidt [EMAIL PROTECTED]\n\n); -printf gtx(deluser is based on adduser by Guy Maor [EMAIL PROTECTED], Ian Murdock\n, +printf gtx(deluser is based on adduser by Guy Maor [EMAIL PROTECTED], Ian Murdock\n. [EMAIL PROTECTED] and Ted Hajek [EMAIL PROTECTED]\n); printf gtx(\nThis program is free software; you can redistribute it and/or modify diff -ur adduser-3.76.old/po/Makefile adduser-3.76/po/Makefile --- adduser-3.76.old/po/Makefile2005-10-22 21:08:37.0 +0200 +++ adduser-3.76/po/Makefile2005-10-24 23:35:29.0 +0200 @@ -1,4 +1,4 @@ -XGETTEXT = xgettext -c +XGETTEXT = xgettext MSGFMT = msgfmt MSGMERGE = msgmerge @@ -12,6 +12,7 @@ PO = $(wildcard *.po) LANG = $(basename $(PO)) MO = $(addsuffix .mo,$(LANG)) +SOURCES = ../adduser ../deluser ../AdduserCommon.pm all: update $(MO) update: adduser.pot @@ -20,8 +21,8 @@ $(MSGMERGE) -U $$po adduser.pot; \ done; -adduser.pot: ../adduser ../deluser ../AdduserCommon.pm - $(XGETTEXT) -L Perl -kgtx -o $@ $? +adduser.pot: $(SOURCES) + $(XGETTEXT) -c -L Perl -kgtx -o $@ $(SOURCES) install: all for i in $(MO) ; do \
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Mon, Oct 24, 2005 at 11:51:56PM +0200, Denis Barbier wrote: On Sat, Oct 22, 2005 at 09:02:28PM +0200, Marc Haber wrote: Of course this comment may be improved ;) You need to call xgettext with the -c flag so that comments are inserted into PO files. that would be XGETTEXT = xgettext -c in po/Makefile, right? Done. Hmmm, I prefer adding -c after $(XGETTEXT). Changed. There is another glitch with po/Makefile: adduser-3.76/po$ touch ../adduser adduser-3.76/po$ make adduser.pot xgettext -c -L Perl -kgtx -o adduser.pot ../adduser Strings from deluser are then discarded. Patch attached. Applied. Yes, but xgettext still displays a warning. In AdduserCommon.pm, you can replace sub gtx { return gettext( join , @_); } by sub gtx { return gettext(shift): } to remove this warning. Calling gtx with a list is wrong, because only the first string is extracted into the POT file (see the attached patch, the 2nd string from deluser is not in adduser.pot). Applied. Here is a patch. I tested it, but of course it may introduce bugs, please review it carefully ;) I applied the changes, but left gtx intact. Please reconsider this suggestion. Frankly, I see no reason to keep this wrapper. If you do not want localized messages, run your scripts with LC_ALL=C. It is consistent with the way gettext is used in C programs, and it allows gettext to be disabled completely, which might be an advantage on low memory systems. I have committed your changes and will upload 3.78 later today. Can you then please take a new look at the package? Greetings Marc -- - Marc Haber | I don't trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things.Winona Ryder | Fon: *49 621 72739834 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Sat, Oct 22, 2005 at 12:02:43AM +0200, Denis Barbier wrote: There is very good documentation in libc.info, section Yes-or-No Questions, but unfortunately it is not relevant here because adduser is a perl script. So I had a look at perllocale(1), which has some nice tips, in particular about I18N::Langinfo. But be warned that their example is not very valuable under GNU/Linux, because glibc introduced YESSTR/NOSTR lately and many locales do not provide them. On the other hand, they all provide YESEXPR/NOEXPR, so you can run something like: use I18N::Langinfo qw(langinfo YESEXPR); my $yesexpr = langinfo(YESEXPR()); for (;;) { systemcall('/usr/bin/chfn', $new_name); # Translators: [y/N] has to be replaced by values defined in your # locale. You can see by running locale yesexpr which regular # expression will be checked to find positive answer. print (gtx(Is the information correct? [y/N] )); chop ($answer=STDIN); last if ($answer =~ m/$yesexpr/o); } Applied, thanks. Of course this comment may be improved ;) You need to call xgettext with the -c flag so that comments are inserted into PO files. that would be XGETTEXT = xgettext -c in po/Makefile, right? Done. Other minor i18n problems with your package: * the gtx() function is useless and confuses xgettext gtx was named _ previously and is obviously modeled after the _ macro suggested in the gettext texinfo documentation. I'd like to keep it to be able to disable i18n for testing and debugging purposes. Unfortunately, it cannot be named _ as File::Find starts to behave very strangely when a function called _ is in the namespace. Is it possible to overload gettext with a no-op for testing purposes? If so, your changes are acceptable. I'd like to have gettext in a state where it can be disabled. Can't xgettexts confusion be remedied by replacing -k_ with -kgtx in the Makefile? I have tried this in the lastest upload to experimental, please verify. Here is a patch. I tested it, but of course it may introduce bugs, please review it carefully ;) I applied the changes, but left gtx intact. Please reconsider this suggestion. s_print (gtx(Backing up files to be removed to . $config{backup_to}. ...\n)); Doesn't this cause translation pain as well? I have changed it to s_printf (gtx(Backing up files to be removed to %s ...\n),$config{backup_to}); -- - Marc Haber | I don't trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things.Winona Ryder | Fon: *49 621 72739834 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Fri, Oct 21, 2005 at 08:36:10AM +0200, Christian Perrier wrote: (Marc pinged me on IRC about this bug report in adduser) Thanks for your help! First of all, I think that adduser should probably make better use of the locales information for this Yes/No answer. I think that would be a good idea here. I don't have the required skills to lead you to the solution, Marc, but I think that Denis Barbier could. Thanks for directly Ccing him, I hope that he can find the time to help. This fr.po file for adduser is under work now and you should soon have a new version anyway with these fixes among others. OK, I'll wait for that before applying stuff. Better not mess with things that I don't understand. Greetings Marc -- - Marc Haber | I don't trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things.Winona Ryder | Fon: *49 621 72739834 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
This fr.po file for adduser is under work now and you should soon have a new version anyway with these fixes among others. OK, I'll wait for that before applying stuff. Better not mess with things that I don't understand. You should also have an incoming mail by Thomas Huriaux (thomash on IRC) who mentioned me a problem in the package build system, as the package is built with svn-buildpackage, but re-synced PO files are not re-commited to your SVN...which is thus always outdated..:-) (at least, this is Thomas analysis) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Fri, Oct 21, 2005 at 06:03:34PM +0200, Christian Perrier wrote: This fr.po file for adduser is under work now and you should soon have a new version anyway with these fixes among others. OK, I'll wait for that before applying stuff. Better not mess with things that I don't understand. You should also have an incoming mail by Thomas Huriaux (thomash on IRC) who mentioned me a problem in the package build system, as the package is built with svn-buildpackage, but re-synced PO files are not re-commited to your SVN...which is thus always outdated..:-) (at least, this is Thomas analysis) I need to learn more about these processes, what gets done at which phase of package building. And obviously, there is no easy document available yet. Greetings Marc -- - Marc Haber | I don't trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things.Winona Ryder | Fon: *49 621 72739834 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#224301: [Adduser-devel] Bug#224301: Some thoughts about this bug report
On Fri, Oct 21, 2005 at 09:23:36AM +0200, Marc Haber wrote: On Fri, Oct 21, 2005 at 08:36:10AM +0200, Christian Perrier wrote: (Marc pinged me on IRC about this bug report in adduser) Thanks for your help! First of all, I think that adduser should probably make better use of the locales information for this Yes/No answer. I think that would be a good idea here. I don't have the required skills to lead you to the solution, Marc, but I think that Denis Barbier could. Thanks for directly Ccing him, I hope that he can find the time to help. This fr.po file for adduser is under work now and you should soon have a new version anyway with these fixes among others. OK, I'll wait for that before applying stuff. Better not mess with things that I don't understand. Hi, There is very good documentation in libc.info, section Yes-or-No Questions, but unfortunately it is not relevant here because adduser is a perl script. So I had a look at perllocale(1), which has some nice tips, in particular about I18N::Langinfo. But be warned that their example is not very valuable under GNU/Linux, because glibc introduced YESSTR/NOSTR lately and many locales do not provide them. On the other hand, they all provide YESEXPR/NOEXPR, so you can run something like: use I18N::Langinfo qw(langinfo YESEXPR); my $yesexpr = langinfo(YESEXPR()); for (;;) { systemcall('/usr/bin/chfn', $new_name); # Translators: [y/N] has to be replaced by values defined in your # locale. You can see by running locale yesexpr which regular # expression will be checked to find positive answer. print (gtx(Is the information correct? [y/N] )); chop ($answer=STDIN); last if ($answer =~ m/$yesexpr/o); } Of course this comment may be improved ;) You need to call xgettext with the -c flag so that comments are inserted into PO files. Other minor i18n problems with your package: * the gtx() function is useless and confuses xgettext * Some msgid are concatenated to build a full sentence. This is bad. and in this case only the first part was present in PO files. Here is a patch. I tested it, but of course it may introduce bugs, please review it carefully ;) Denis diff -ur adduser-3.74.orig/AdduserCommon.pm adduser-3.74/AdduserCommon.pm --- adduser-3.74.orig/AdduserCommon.pm 2005-10-18 16:20:00.0 +0200 +++ adduser-3.74/AdduserCommon.pm 2005-10-21 23:49:30.0 +0200 @@ -10,7 +10,7 @@ # Ian A. Murdock [EMAIL PROTECTED] # [EMAIL PROTECTED] = qw(invalidate_nscd gtx dief warnf read_config get_users_groups get_group_members s_print s_printf systemcall); [EMAIL PROTECTED] = qw(invalidate_nscd dief warnf read_config get_users_groups get_group_members s_print s_printf systemcall); sub invalidate_nscd { # Check if we need to do make -C /var/yp for NIS @@ -56,10 +56,6 @@ } } -sub gtx { -return gettext( join , @_); -} - sub dief { my ($form,@argu)[EMAIL PROTECTED]; printf STDERR $0: $form,@argu; @@ -80,7 +76,7 @@ my ($var, $lcvar, $val); if (! -f $conf_file) { - printf gtx(%s: `%s' doesn't exist. Using defaults.\n),$0,$conf_file if $verbose; + printf gettext(%s: `%s' doesn't exist. Using defaults.\n),$0,$conf_file if $verbose; return; } @@ -90,12 +86,12 @@ next if /^#/ || /^\s*$/; if ((($var, $val) = /^\s*(\S+)\s*=\s*(.*)/) != 2) { - warnf gtx(Couldn't parse `%s':%s.\n),$conf_file,$.; + warnf gettext(Couldn't parse `%s':%s.\n),$conf_file,$.; next; } $lcvar = lc $var; if (!defined($configref-{$lcvar})) { - warnf gtx(Unknown variable `%s' at `%s':%s.\n),$var,$conf_file,$.; + warnf gettext(Unknown variable `%s' at `%s':%s.\n),$var,$conf_file,$.; next; } diff -ur adduser-3.74.orig/adduser adduser-3.74/adduser --- adduser-3.74.orig/adduser 2005-10-19 15:09:09.0 +0200 +++ adduser-3.74/adduser2005-10-21 23:45:02.0 +0200 @@ -48,10 +48,19 @@ if ($@) { *setlocale = sub { return 1 }; } +eval { + require I18N::Langinfo; + import I18N::Langinfo qw(langinfo YESEXPR); +}; +if ($@) { + *langinfo = sub { ^[yY] }; + *YESEXPR = sub { 1 }; +} } setlocale(LC_MESSAGES, ); textdomain(adduser); +my $yesexpr = langinfo(YESEXPR()); our $verbose = 1; # should we be verbose? my $allow_badname = 0; # should we allow bad names? @@ -86,7 +95,7 @@ debug = \$debugging ); # everyone can issue --help and --version, but only root can go on -die ($0: ,gtx(Only root may add a user or group to the system.\n)) if ($ != 0); +die ($0: ,gettext(Only root may add a user or group to the system.\n)) if ($ != 0); if( defined($configfile) ) { @defaults = ($configfile); } @@ -106,30 +115,30 @@ while (defined($arg = shift(@ARGV))) { if (defined($names[0]) $arg =~ /^--/) {