guastallaigor / vue-paycard

Credit card component made with Vue.js (works with Vue 2 & 3)
https://vue-paycard.netlify.app
MIT License
106 stars 23 forks source link

Change labels to other language #10

Closed souzadavi closed 3 years ago

souzadavi commented 3 years ago

Please could you give some example to change the labels to other language? I didn't figure out how to translate the Card Holder and Expires info on card image.

Thanks to share this improvement, i'm using on quasar project.

guastallaigor commented 3 years ago

Hello @souzadavi A basic example would be something like this:

<template>
  <div id="app">
    <vue-paycard :value-fields="valueFields" :labels="labels" />
  </div>
</template>

<script>
export default {
  data: () => ({
    labels: {
      cardName: "Igor Guastalla",
      cardHolder: "Nome Completo",
      cardMonth: "MM",
      cardYear: "YY",
      cardExpires: "Expiração",
      cardCvv: "CVV",
    },
    valueFields: {
      cardName: "",
      cardNumber: "",
      cardMonth: "",
      cardYear: "",
      cardCvv: "",
    },
  }),
};
</script>

image

You will need to make the labels prop dynamic, maybe using a computed property in your project, if you want to support multiple languages.

Maybe the problem you had is because I notice that storybook has a bug in version 6.0+ using object knobs. I migrate it to controls and now everything should work fine.

Anything else, let me know.