elixir-gettext / gettext

Internationalization and localization support for Elixir.
https://hexdocs.pm/gettext
461 stars 87 forks source link

Mention file path in plural forms deprecation warning #360

Closed NobbZ closed 10 months ago

NobbZ commented 1 year ago

gettext issues several warnings with the following text during compilation:

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 "en" locale, you can use the following header:

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

This warning does not explain well how to fix it.

It refers to Gettext.Plural, which itself does not mention how to transition from "plural forms" to "plural forms headers".

It also does not mention, which file specifies the deprecated plural-forms.

git grep over the project does not give any result for nplurals at all.

The projects Gettext module is just like this:

defmodule ExampleWeb.Gettext do
  use Gettext, otp_app: :example
end

Can this warning or the Gettext.Plural more precise instructions for the transition from the wrong to the correct form?

maennchen commented 1 year ago

@NobbZ

It also does not mention, which file specifies the deprecated plural-forms.

I think it would make sense to write the affected file path into the error message. A PR for that is very welcome.

git grep over the project does not give any result for nplurals at all.

git grep works fine for all of my repositories. Is it possible that you configured something for the files in .gitattributes?

NobbZ commented 1 year ago

In the meantime we were able to resolve the issue by removing most gettext related things from our Repo. It was a pure API anyway. The dependency itself and some "empty" translation files remain for now, as some deeply burried dependency requires that we have set up the application on our side.

The hint with the .gitattributes though was helpful.

*.po and *.pot files have been marked as "binary" and probably skipped by git grep because of that.

Trying git grep again on a previous commit that had those warnings, successfully found the problematic lines after removing the offending attributes.

maennchen commented 10 months ago

The vast majority of our users seems to have updated in the meantime. I no longer believe that an improvement of the error would still have a significant impact. I'm therefore closing the issue. Please reopen / comment, if you don't agree.

ggarciajr commented 9 months ago

I just came stumbled on this error message and I have no idea how to fix. Having at least some guidance on what to do to fix would be extremely helpful @maennchen

after spending sometime on this, I figured I had to modify my po files from "Plural-Forms: nplurals=2;\n" to "Plural-Forms: nplurals=2; plural=(n != 1);\n"