bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [WIP-PATCHES] Lisp (and Scheme) jump format specifier and ngettext


From: Bruno Haible
Subject: Re: [WIP-PATCHES] Lisp (and Scheme) jump format specifier and ngettext
Date: Sat, 28 Nov 2020 00:17:28 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-193-generic; KDE/5.18.0; x86_64; ; )

Hi Miguel,

> > The second patch is right as well. Simply, I had never thought at explicitly
> > listing plural cases in these unit tests.
> > [...]
> > Yes, it would be useful to add this test to the test suite.
> 
> I've joined them, because they are mostly plural case tests.  With your
> guidance I came to the second patch, which solves both issues.  What do
> you think?

Thanks for working on this.

It is OK to join the changes for Lisp and for Scheme in a single patch,
since it does effectively the same thing.

I agree that replacing the 'make_intersected_list' in format_check is the
way to do. But I think the implementation of that check should do a
different thing.

Namely, the difference between messages with no plural and messages with
plural is *only* that the message with plural some cases don't need to
mention an integer argument since it is known from the plural form.

Let's take an example:

  msgid "~d translated message"
  msgid_plural "~d translated messages"
  msgstr[0] "un message traduit"
  msgstr[1] "~d messages traduits"

Excluding n=0, and assuming the French plural form formula plural=(n > 1),
the integer argument can be ignored in msgstr[0] because the translator
knows that it is always == 1.

That's the *only* reason why a translator is supposed to use different
format directives in the translation.

Therefore in the test suite, we should not only add

  # Invalid: narrowing type on the translation
  msgid "~a thing"
  msgid_plural "~a things"
  msgstr[0] "~d thing"
  msgstr[1] "~d things"

but also

  # Invalid: widening type on the translation
  msgid "~d thing"
  msgid_plural "~d things"
  msgstr[0] "~a thing"
  msgstr[1] "~a things"

Omitting a ~d format directive should be valid:

  # Valid: omitting an integer-typed variable
  msgid "~d thing"
  msgid_plural "~d things"
  msgstr[0] "the thing"
  msgstr[1] "the ~d things"

Whereas omitting a ~a or ~s format directive should be invalid:

  # Invalid: omitting an object-typed variable
  msgid "~a's ~d thing"
  msgid_plural "~a's ~d things"
  msgstr[0] "the ~d thing"
  msgstr[1] "the ~a's ~d things"

  # Invalid: omitting an object-typed variable
  msgid "~s ~d thing"
  msgid_plural "~s ~d things"
  msgstr[0] "the ~d thing"
  msgstr[1] "the ~s ~d things"

Does this make sense to you?

If yes, can you add more such tests? When working on xgettext, because of
the complexity of the code involved, I like to use a test-driven coding
approach: First add more test cases to the test suite, then only implement
the code that does it.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]