Skip to content

Why the vue-lang do not work with filter?

I using vue-lang. It works, but not completely


in the JSON file there is an example of:

"messages": "You have {0} {1} messages"

and then this code as a filter

<p>{{$lang.messages | replace countmsg 'new'}}</p>

But when I do it by example so there is an error here

[Vue warn]: Failed to resolve filter: replace countmsg 'new'



import Vue from 'vue'
import Lang from 'vue-lang'
const locales = {
  'cs': require('./lang/cs.json')
Vue.use(Lang, {lang: 'cs', locales: locales})


  "messages": "You have {0} {1} messages"


  <p>{{$lang.messages | replace countmsg 'new'}}</p>
  export default {
  name: 'Login',
  data: function() {
    return {
      countmsg: 5

Still does not work. What am I doing wrong?


I’m not familiar with this particular library but the usual way to use a filter like this would be:

{{ $lang.messages | replace(countmsg, 'new') }}

The documentation for that filter appears to be 3 years old so it may be out of date. The syntax for calling filters was changed some time ago: