gettext icon indicating copy to clipboard operation
gettext copied to clipboard

Include file in plural warnings?

Open tmjoen opened this issue 1 year ago • 3 comments

I'm getting warnings about Plural-Forms:

warning: Plural-Forms headers in the form "nplurals=<int>" (without the "plural=<rule>" part following) are invalid and support for them will be removed in future Gettext versions. Make sure to use a complete Plural-Forms header, which also specifies the pluralization rules, or remove the Plural-Forms header completely. If you do the latter, Gettext will use its built-in pluralization rules for the languages it knows about (see Gettext.Plural).
For the "no" locale, you can use the following header:

nplurals=2; plural=(n != 1);

  (gettext 0.26.2) lib/gettext/plural.ex:282: Gettext.Plural.init/1
  (gettext 0.26.2) lib/gettext/compiler.ex:570: Gettext.Compiler.compile_plural_forms/4
  (gettext 0.26.2) lib/gettext/compiler.ex:508: Gettext.Compiler.compile_po_file/5
  (gettext 0.26.2) lib/gettext/compiler.ex:447: Gettext.Compiler.compile_unified_po_file/4
  (elixir 1.17.3) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
  (gettext 0.26.2) lib/gettext/compiler.ex:72: Gettext.Compiler."MACRO-__before_compile__"/2

However, I don't have any invalid Plural-Forms in my project, I'm using the same header as is suggested in the warning message. Which means it could possibly stem from a dep? But which dep? The warnings get awfully noisy when there are so many!

Is there a way to log where the warning stems from?

tmjoen avatar Jan 02 '25 14:01 tmjoen

This was already addressed in #406 but is unfortunately not yet released. Will do one once I’m back from my vacation.

maennchen avatar Jan 02 '25 15:01 maennchen

That looks like it's just for the warning for the old syntax, no? This is about the plural warning, which looks identical to me on main:

https://github.com/elixir-gettext/gettext/blob/main/lib/gettext/plural.ex#L278-L289

tmjoen avatar Jan 02 '25 15:01 tmjoen

Oh, sorry. Reopening.

A PR would be welcome 😊

maennchen avatar Jan 02 '25 15:01 maennchen