Closed Sinc63 closed 1 year ago
@Sinc63 I've tried to replicate your issue and was unable to.
I used an existing project with the latest gettext
& expo
dependencies. In there I called mix gettext.merge priv/gettext --locale pl
(pl
is not a locale we have so far) and the generated priv/gettext/pl/LC_MESSAGES/default.po
starts like this:
# ...
msgid ""
msgstr ""
"Language: pl\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10||n%100>=20) ? 1 : 2);\n"
# ...
Can you create me a reproduction repo so that I can reproduce your issue?
It might even be nice if the warning would automatically update an existing file
While that would be nice, judging by the amount of downloads of recent versions of the lib on hex.pm, It would probably no longer benefit a lot of users at this point.
I just tried it again. Cleared out the cs directory to start. Same result. I ran:
mix do gettext.extract, gettext.merge priv/gettext --no-fuzzy
My cs file starts with:
## "msgid"s in this file come from POT (.pot) files.
###
### Do not add, change, or remove "msgid"s manually here as
### they're tied to the ones in the corresponding POT file
### (with the same domain).
###
### Use "mix gettext.extract --merge" or "mix gettext.merge"
### to merge POT files into PO files.
msgid ""
msgstr ""
"Language: cs\n"
"Plural-Forms: nplurals=3\n"
[root]# grep gettext mix. mix.exs: {:gettext, "~> 0.18"}, mix.lock: "gettext": {:hex, :gettext, "0.22.0", "a25d71ec21b1848957d9207b81fd61cb25161688d282d58bdafef74c2270bdc4", [:mix], [{:expo, "~> 0.3.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "cb0675141576f73720c8e49b4f0fd3f2c69f0cd8c218202724d4aebab8c70ace"}, [root]# grep expo mix. mix.lock: "expo": {:hex, :expo, "0.3.0", "13127c1d5f653b2927f2616a4c9ace5ae372efd67c7c2693b87fd0fdc30c6feb", [:mix], [], "hexpm", "fb3cd4bf012a77bc1608915497dae2ff684a06f0fa633c7afa90c4d72b881823"}, mix.lock: "gettext": {:hex, :gettext, "0.22.0", "a25d71ec21b1848957d9207b81fd61cb25161688d282d58bdafef74c2270bdc4", [:mix], [{:expo, "~> 0.3.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "cb0675141576f73720c8e49b4f0fd3f2c69f0cd8c218202724d4aebab8c70ace"},
I see that there is a 0.4 of expo - and it looks like if I switch from 0.22.0 to 0.22.1 it works properly. So I switched. Guess I better do that for my other repo too.
It's hard to keep up with changes to every dependency. Especially in my other repo that has 151 dependencies. This one only has 52.
I tried looking for a duplicate problem but didn't find one. (I did find a nice new option to exclude line numbers and avoid unnecessary churn on my other project with 1500 translations though, so that was good.) If you have the means to tag this problem against the creation of 0.4 that might help future folk like me.
My newly joined project has numerous warnings about the plural forms being missing from several files (as Nobbz pointed out in https://github.com/elixir-gettext/gettext/issues/360, in unspecified files). I fixed these, then added a new language directory and generated the translation files for it, and it gave me the same plural forms warnings. (I'm using 0.22.0)
If it is necessary to warn about plural forms, then a newly generated file needs to automatically specify the plural forms correctly. The warning detects the language and gives the suggested form, so that form should be included in a newly generated file.
(It might even be nice if the warning would automatically update an existing file, or if running a merge would do so, with a warning that it was being done automatically.)