1

I'm trying to display a notification based on a value returned by the server. I don't know how to retrieve the translation value dynamically using the value of the key just received.

For example, the value of error.response.data.errorDetailsCode is "invalid_credentials", and the translation is "Invalid credentials provided"

import i18n from './i18n';

$.notify({message: i18n.t("error.response.data.errorDetailsCode")}, options);

I get this warning on the console:

vue-i18n.esm.js?a925:14 [vue-i18n] Cannot translate the value of keypath 'invalid_credentials'. Use the value of keypath as default.

1 Answer 1

1

Finally found the way:

$.notify(message: i18n.t(`${error.response.data.errorDetailsCode}`)}, options);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.