[systemd-devel] loginctl grammar.

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Aug 26 05:46:21 PDT 2013


On Mon, Aug 26, 2013 at 03:15:28PM +0300, Apostolos Bartziokas wrote:
> Hello.
> 
> When you use loginctl list _xxxxx_ in a single user/seat/session
> system it displays 1 session*s*/user*s*/seat*s*. Shouldn't the code
> for it be something like the attached patch??
Hi,
you are right that the output is suboptimal. But the way
this should be coded is different: plural versions are done
as a side effect of localization, i.e. using the gettext
library to substitute translated strings for such messages.
This is done by marking the string in a special way,
and then using semi-automated tools to extract the string
and keep a table of translations in po/<language>.po.
Since various languages have different rules about what
is plural, or have more than one plural grammatical form,
etc., the translation lookup function also gets the number
to be substituted in the template string, and can pick the
right singular/plural version.

We have some gettext support, but this part of systemd has
languished, and it would be great if somebody could pick
it up. The job involves two interrelated parts (which often
are done by different people though): 
- marking strings as "translatable":
  printf(_N("\n%u sessions listed.\n", k), k);
- actually providing the translation to 
  "\n%u sessions listed.\n",
  e.g. "\n%uWyświetlono %u sesji.\n" (polish).

If you look at e.g. po/pl.po, there are lines with empty
'msgstr ""' — those are the ones that need translating
or updating.

Zbyszek

> 136,137c136,141
> <         if (on_tty())
> <                 printf("\n%u sessions listed.\n", k);
> ---
> >         if (on_tty()) {
> > 		if (k==1)
> > 			printf("\n%u session listed.\n", k);
> > 		else
> >                 	printf("\n%u sessions listed.\n", k);
> > 	}
> 199,200c203,208
> <         if (on_tty())
> <                 printf("\n%u users listed.\n", k);
> ---
> >         if (on_tty()) {
> > 		if (k==1)
> > 			printf("\n%u user listed.\n", k);
> > 		else
> >                 	printf("\n%u users listed.\n", k);
> > 	}
> 260,262c268,273
> <         if (on_tty())
> <                 printf("\n%u seats listed.\n", k);
> < 
> ---
> >         if (on_tty()) {
> > 		if (k==1)
> > 			printf("\n%u seat listed.\n", k);
> > 		else
> >                 	printf("\n%u seats listed.\n", k);
> > 	}

> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel



More information about the systemd-devel mailing list