i18next-parser icon indicating copy to clipboard operation
i18next-parser copied to clipboard

Please add this.$t in vue, now only this.$i18n.t is supported

Open gustawdaniel opened this issue 4 years ago • 2 comments

In vue files in script section there are great support for function

this.$i18n.t

but function

this.$t

is skipped.

gustawdaniel avatar Feb 26 '21 00:02 gustawdaniel

I found another problems

  1. In template props of input:
:placeholder="$t('select.placeholder', {type: $t('select.category')})"
  • select.placeholder - detected correctly
  • select.category - skipped
  1. If one component imports other then in this component translations inside of script are skipped.

gustawdaniel avatar Feb 26 '21 01:02 gustawdaniel

What do you mean by "in script section"? If you want to add a function to parse, you should be able to configure the lexer:

vue: [{
    lexer: 'JavascriptLexer',
    functions: ['$i18n.t', '$t'], // Array of functions to match
  }],

For 1., you are welcome to open a PR to fix it.

For 2. this project is a stupid parser, not an interpreter. You must tell it which files to parse and I'm not keen to add any kind of magic such as following imports in the code.

karellm avatar Feb 26 '21 08:02 karellm