vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

If $t params are undefined

Open martinlundin opened this issue 3 years ago • 0 comments
trafficstars

Reporting a bug?

When using a variable as a param to the $t() function it works good until the variable is undefined. Then there is an error: Uncaught (in promise) SyntaxError: Invalid argument

Expected behavior

In previous versions this was handled by the function.

Reproduction

I made a JSFiddle here https://jsfiddle.net/rxn13fa7/4/ Its the "undefined" on row 28 that creates the error. Remove it and it works fine.

System Info

See JSFiddle

Screenshot

No response

Additional context

The current solution I do is making a wrapping function like this translate (key) { return key ? this.$t(key) : '' }

Validations

martinlundin avatar Sep 01 '22 09:09 martinlundin