[pacman-dev] [RFC v3 13/13] bacman: make gettext useful
Gordian Edenhofer
gordian.edenhofer at gmail.com
Fri Sep 30 12:50:43 UTC 2016
On Fri, 2016-09-30 at 08:14 -0400, Dave Reisner wrote:
> On Fri, Sep 30, 2016 at 01:48:01PM +0200, Gordian Edenhofer wrote:
> >
> > Export TEXTDOMAIN and TEXTDOMAINDIR in order for the strings to be
> > translatable with gettext.
> > ---
> > contrib/bacman.sh.in | 28 ++++++++++++++++++++++------
> > 1 file changed, 22 insertions(+), 6 deletions(-)
> >
> > diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
> > index 39fbe99..cc243c9 100644
> > --- a/contrib/bacman.sh.in
> > +++ b/contrib/bacman.sh.in
> > @@ -32,6 +32,17 @@ QUIET=0
> > # Required for fakeroot because options are shifted off the array.
> > ARGS=("$@")
> >
> > +# gettext initialization
> > +export TEXTDOMAIN='pacman'
> > +export TEXTDOMAINDIR='@localedir@'
> > +
> > +# Determine whether we have gettext; make it a no-op if we do not
> > +if ! type -p gettext >/dev/null; then
> > + gettext() {
> > + printf "%s\n" "$@"
>
> Not sure if this is copypasted from somewhere, but it's wrong.
> Consider
> the output of:
>
> printf '%s\n' 1 2 3
>
> vs.
>
> printf '%s\n' '1 2 3'
>
> You probably wanted this to be: printf '%s\n' "$*"
Yes, this is indeed copy-pasted from makepkg [1] since I though it
would be properly scripted there.
> > + }
> > +fi
> > +
> > m4_include(../scripts/library/output_format.sh)
> > m4_include(../scripts/library/parseopts.sh)
> >
> > @@ -54,13 +65,18 @@ usage() {
> > printf -- "$(gettext "Usage: %s [options]
> > <package(s)>")\n" "$0"
> > echo
> > printf -- "$(gettext "Options:")\n"
> > - printf -- "$(gettext " -h, --help Show this help
> > message and exit")\n"
> > - printf -- "$(gettext " -q, --quiet Silence most of
> > the status reporting")\n"
> > - printf -- "$(gettext " -m, --nocolor Disable colorized
> > output messages")\n"
> > - printf -- "$(gettext " -o, --out <dir> Write output to
> > specified directory (instead of \$PKGDEST)")\n"
> > - printf -- "$(gettext " --pacnew Package .pacnew
> > files")\n"
> > + printf -- " -h, --help "
> > + printf -- "$(gettext "Show this help message and exit")\n"
>
> This splitting/wrapping doesn't really make me think that this is an
> improvement. Other patches are subjectively worse IMO -- particularly
> cases where the usage wraps onto multiple lines and you're adding
> arbitrary amounts of whitespace wrapping. It's hard to get right and
> I
> suspect it'll be broken in the future. There's a reason I used a
> heredoc
> for paccache's usage function. It's natural, reads easily, and is
> easy
> to extend.
>
> Still wondering if we actually care about translations for contrib,
> or
> if we care about contrib at all.
I really like heredocs and initially submitted my bacman patch using
them for the very same reasons you mentioned. However I was advised to
follow the style from scripts like makepkg, repo-add etc.
[1] https://git.archlinux.org/pacman.git/tree/scripts/makepkg.sh.in#n12
26
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20160930/a894b50b/attachment.asc>
More information about the pacman-dev
mailing list