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

Assets and routes #32

Closed
lucpotage opened this issue Feb 23, 2018 · 3 comments
Closed

Assets and routes #32

lucpotage opened this issue Feb 23, 2018 · 3 comments

Comments

@lucpotage
Copy link

lucpotage commented Feb 23, 2018

I try to bind my image src attribute and use a path that depends on the current locale:

<img :src="'~/assets/image-' + $i18n.locale + '.svg'">

However it does not work and the output is:

<img src="~/assets/image-en.svg">

Another issue is with video posters, my paths don't work. Any idea?

<video poster="~/assets/poster.png">...</video>

This question is available on Nuxt.js community (#c15)
@TheAlexLichter
Copy link
Contributor

TheAlexLichter commented Feb 25, 2018

You cannot use "dynamic paths" that change at runtime because webpack evaluates them before.

An easy solution for this is to move the images in the static folder and link to them with :src= "'/image-' + $i18n.locale + '.svg'". If that's (whyever) not wanted, you can also use require (:src="require('~/assets/image-' + $i18n.locale + '.svg')")

@ghost
Copy link

ghost commented Aug 11, 2018

This question has been resolved by @manniL, see answer.

@ghost ghost added the cmty:status:resolved label Aug 11, 2018
@nelsonlarocca
Copy link

so for each image also we would need to check if the image exists otherwise get the "fallback" one.

farnabaz added a commit to farnabaz/i18n-module that referenced this issue Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants