0

I integrated i18n-next in my Vue3 project and it works for elements like headers or labels with the known syntax {{ $t ("something") }}, but I can't get it to work with the value or placeholder of things like <input type="submit" value="This should be variable" class=... /> What is the correct way to do this?

2
  • 2
    As I don't know i18n-next I just post this as a comment: Can't you just bind it like normal attributes and props? <input type="submit" :value="$t('placeholder')" class=... /> Commented Nov 19, 2021 at 8:07
  • This is just the way it works. Thanks a lot - I am pretty new to Vue and I had no idea, that the v-bind directive is the way to go here. Commented Nov 19, 2021 at 17:18

2 Answers 2

0

Just like Thomas mentioned in the above comment, this is how it works:

<input type="submit" :value="$t('valuename')" class=.. />
Sign up to request clarification or add additional context in comments.

Comments

0

Solution for use i18n in input placeholder and value in Vue3.js and Nuxt3.js

For placeholder you must add empty space or string to $t('something') equal :placeholder="$t('something')+' '"

but for value just $t('something') equal :value="$t('something')"

Your code

<input type="submit" :placeholder="$t('something')+' '" :value="$t('something')" class="" />

#or

<input type="submit" :placeholder="$t('something')+'.'" :value="$t('something')" class="" />

Sample code search

<input type="text" :placeholder="$t('what_are_you_looking_for')+' '" :value="$t('what_are_you_looking_for')" class="form-control">

#or

<input type="text" :placeholder="$t('what_are_you_looking_for')+'...'" :value="$t('what_are_you_looking_for')" class="form-control">

Finish!

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.