xiCO2k / laravel-vue-i18n

Allows to connect your `Laravel` Framework translation files with `Vue`.
MIT License
594 stars 49 forks source link

[Question] Access $t inside a persistent layout #102

Closed mariusberget92 closed 1 year ago

mariusberget92 commented 1 year ago

Is it possible to access $t inside the persistent layout? I am trying to set a page title based on plural form of a model, needing $t('User|Users', 2) like this:

layout: (h, page) => {
  return h(VLayout, { pageTitle: $t('User|Users', 2) }, () => page);
},

It throws a undefined error. I did kind of expect it though, just wondering if there's a way to access $t in there.

xiCO2k commented 1 year ago

you have to use trans() method..

import { trans } from 'laravel-vue-i18n'