Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile issue with Gettext 0.14.0 #9

Closed
isaiahdw opened this issue Jan 24, 2018 · 5 comments
Closed

Compile issue with Gettext 0.14.0 #9

isaiahdw opened this issue Jan 24, 2018 · 5 comments

Comments

@isaiahdw
Copy link

Anyone else having issues compiling with the latest Gettext version? I'm getting the following error:

== Compilation error in file lib/not_qwerty123/password_strength.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(NotQwerty123.Gettext, string)

    (gettext) lib/gettext/compiler.ex:213: Gettext.Compiler.expand_to_binary/4
    expanding macro: NotQwerty123.Gettext.dgettext_noop/2
    lib/not_qwerty123/password_strength.ex:56: NotQwerty123.PasswordStrength.strong_password?/2
    expanding macro: NotQwerty123.Gettext.dgettext/3
    lib/not_qwerty123/password_strength.ex:56: NotQwerty123.PasswordStrength.strong_password?/2
    expanding macro: NotQwerty123.Gettext.gettext/2
    lib/not_qwerty123/password_strength.ex:56: NotQwerty123.PasswordStrength.strong_password?/2
    (elixir) expanding macro: Kernel.if/2
@Betree
Copy link
Contributor

Betree commented Jan 24, 2018

I had this issue with an old version (0.11.x I think ?) but updating to Gettext 0.13.1 fixed it for me.
A lot of libraries are impacted by this, for example ex_admin (see smpallen99/ex_admin#425).

It happens when gettext is presented with strings concatenations like text gettext "toTranslate" <> " ". Gettext build translations at compile time and for some reasons it fails to recognize this as a valid string.

Try 0.13.1 and if you want to fix it on the library I'm sure @riverrun would like a PR 😉 It's a matter of converting translations like:

markup do
    text gettext "Displaying" <> " "
end

To:

markup do
    text (gettext "Displaying") <> " "
end

@riverrun
Copy link
Owner

Great! Thanks for the useful info.

@riverrun
Copy link
Owner

Just pushed version 2.3, with a fix (I hope), to hex.

Could you try it out and let me know if it works?

@isaiahdw
Copy link
Author

@riverrun, I can confirm 2.3 fixes the issue. Thanks for pushing an update so quickly!

I don't see the changes on github, but feel free to close this issue. 😃

@riverrun
Copy link
Owner

I'll update master today - great to hear that fixed the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants