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

If $t params are undefined #1155

Closed
5 tasks done
martinlundin opened this issue Sep 1, 2022 · 1 comment
Closed
5 tasks done

If $t params are undefined #1155

martinlundin opened this issue Sep 1, 2022 · 1 comment

Comments

@martinlundin
Copy link

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 martinlundin added the Status: Review Needed Request for review comments label Sep 1, 2022
@kazupon kazupon added Type: Bug Bug or Bug fixes Status: PR Welcome Welcome to Pull Request and removed Status: Review Needed Request for review comments labels Sep 5, 2022
@kazupon kazupon added good first issue Good for newcomers 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Nov 15, 2022 — with Volta.net
@kazupon kazupon removed Type: Bug Bug or Bug fixes good first issue Good for newcomers Status: PR Welcome Welcome to Pull Request 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Apr 28, 2024
@kazupon
Copy link
Member

kazupon commented Apr 28, 2024

This is not a bug, but expected behavior.
vue-i18n raises the following error:

vue@3:1839 Uncaught SyntaxError: Invalid argument
    at createCompileError (vue-i18n@9:323:21)
    at createI18nError (vue-i18n@9:3669:14)
    at Object.t (vue-i18n@9:4645:29)
    at Proxy.$t (vue-i18n@9:5826:49)
    at eval (eval at compileToFunction (vue@3:16563:20), <anonymous>:11:57)
    at renderList (vue@3:4446:18)
    at Proxy.render (eval at compileToFunction (vue@3:16563:20), <anonymous>:9:68)
    at renderComponentRoot (vue@3:2459:18)
    at ReactiveEffect.componentUpdateFn [as fn] (vue@3:7510:48)
    at ReactiveEffect.run (vue@3:538:21)```

Invalid argument is outputting that message because there is a problem with the $t argument.

Thanks!

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

2 participants