smpallen99 / ex_admin

ExAdmin is an auto administration package for Elixir and the Phoenix Framework
MIT License
1.2k stars 275 forks source link

Fails to compile with latest gettext #425

Open benrom opened 6 years ago

benrom commented 6 years ago

When compiling my project with both ex_admin@latest and latest gettext@0.14.0, the mix deps.compile build fails after these warnings:

09:50:47.141 [error] /Users/chris/code/elixir_server/_build/dev/lib/ex_admin/priv/gettext/pl_PL/LC_MESSAGES/default.po:6: translation is missing plural form 2 which is required by the locale "pl_PL"
warning: variable "repo" does not exist and is being expanded to "repo()", please use parentheses to remove the ambiguity or change
09:50:47.539 [error] /Users/chris/code/elixir_server/_build/dev/lib/ex_admin/priv/gettext/ru_RU/LC_MESSAGES/default.po:6: translation is missing plural form 2 which is required by the locale "ru_RU"

09:50:47.608 [error] /Users/chris/code/elixir_server/_build/dev/lib/ex_admin/priv/gettext/uk_UA/LC_MESSAGES/default.po:6: translation is missing plural form 2 which is required by the locale "uk_UA"

== Compilation error in file lib/ex_admin/paginate.ex ==
** (ArgumentError) *gettext macros expect translation keys (msgid and msgid_plural) and
domains to expand to strings at compile-time, but the given msgid
doesn't.

Dynamic translations should be avoided as they limit gettext's
ability to extract translations from your source code. If you are
sure you need dynamic lookup, you can use the functions in the Gettext
module:

    string = "hello world"
    Gettext.gettext(ExAdmin.Gettext, string)

    (gettext) lib/gettext/compiler.ex:213: Gettext.Compiler.expand_to_binary/4
    expanding macro: ExAdmin.Gettext.dgettext_noop/2
    lib/ex_admin/paginate.ex:58: ExAdmin.Paginate.pagination_information/2
    expanding macro: ExAdmin.Gettext.dgettext/3
    lib/ex_admin/paginate.ex:58: ExAdmin.Paginate.pagination_information/2
    expanding macro: ExAdmin.Gettext.gettext/1
    lib/ex_admin/paginate.ex:58: ExAdmin.Paginate.pagination_information/2
    (elixir) expanding macro: Kernel.to_string/1
    lib/ex_admin/paginate.ex:58: ExAdmin.Paginate.pagination_information/2
    expanding macro: Xain.text/1
    lib/ex_admin/paginate.ex:58: ExAdmin.Paginate.pagination_information/2
    expanding macro: Xain.markup/1
    lib/ex_admin/paginate.ex:57: ExAdmin.Paginate.pagination_information/2
    (elixir) lib/kernel/parallel_compiler.ex:121: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
could not compile dependency :ex_admin, "mix compile" failed. You can recompile this dependency with "mix deps.compile ex_admin", update it with "mix deps.update ex_admin" or clean it with "mix deps.clean ex_admin"

Another of my dependencies shows warnings during compilation (timex) but it does not break the build.

No such problem with gettext@0.13.1, that must be linked to that new 0.14.0 feature:

Warn when compiling and raise at runtime for missing plural forms

I will stick to 0.13.x for now.

My environment: Erlang/OTP 20 [erts-9.1.4] Elixir 1.5.2

chebykin commented 6 years ago

the same for me

Erlang/OTP 20.1.7 [erts-9.1.5] Elixir 1.5.2


@benrom thanks for the suggested gettext downgrade

cdesch commented 6 years ago

I ran into the same problem on ExAdmin 6783c29ec8e62d36d80c87e69511793a80eb8f7c ({:ex_admin, github: "smpallen99/ex_admin"}, after upgrading to:

  {:coherence, "~> 0.4.0"},
  {:scrivener_ecto, "~> 1.1"},
  {:comeonin, "~> 3.0"},

Changing gettext from

   {:gettext, "~> 0.11"},

to:

  {:gettext, "~> 0.13.1"},

Fixed it for me.


Erlang/OTP 19 [erts-8.2.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] Elixir 1.5.0

ardhitama commented 6 years ago

@smpallen99 can you please check @nghitran 's PR (https://github.com/smpallen99/ex_admin/pull/426) ? will help a lot of people

reubenbrown13 commented 6 years ago

I was running into this issue too. I just put the proposed fix in the 1.3 branch. If you want to fix it on your own, go to the lib/ex_admin/paginate.ex on line 58 and change it to: text (gettext "Displaying ") <> " "