-
Notifications
You must be signed in to change notification settings - Fork 60
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
Error message internationalization #2
Comments
@bruce I have started using vex, and it will be good to have internationalizatio, do you have any plans about it? |
@wafcio, this should be helpful - https://github.com/CargoSense/vex#error-message-renderers |
unfortunatelly it isn't because you have injected counters and different variables to error message, which make impossible to create translation for them. |
I don't understand the trouble. Can you write an example for me? |
when I checked length validator I received |
I don't see why it can't be achieved. Can you drop the code snippet and point the current and expected behavior? |
What if you have different lenght in different places like |
Sorry, I don't really get what you mean by "need to fill new translation key". Some examples of code would definitely help here. Anyway I think this link I posted above still would be useful, because with error renderer you can create any error that you need. If you need no translation or no interpolation, and want to receive original message like ecto changeset does: defmodule MyRenderer do
@behaviour Vex.ErrorRenderer
def message(options, _default, context \\ []), do: {options[:message], context}
end
result = Vex.validate([name: "Foo"], name: [
length: [
min: 4,
error_renderer: MyRenderer,
message: "too short, min %{min} chars"
]
])
assert {:error, [{:error, :name, :length, {"too short, min %{min} chars", [min: 4, ...]}}]} = result I'm not fully sure is it target your issues, and if not, please, drop some snippet of code. |
Probably using: https://github.com/chrismccord/linguist
The text was updated successfully, but these errors were encountered: