Skip to content

dimailn/vue-t

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-t

A small helper which allows you to write contextual translations in Vue.

Installation

npm i --save @dimailn/vue-t

import VueT from '@dimailn/vue-t'
Vue.use(VueT)

Usage

This library provides two computed property for components - $translationScope and $defaultTranslationScope. These properties are inherited from parent components and you may change them by using vueT option. Your translate method should use this properties to determine current scope for translations.

vueT option may be used like this

// This component has $translationScope === 'UserCard', based on name(recommended way)

{
  name: 'UserCard',
  vueT: true
}

or

// This component has $translationScope === 'UserInformation'

{
  name: 'UserCard',
  vueT: 'UserInformation'
}

Now you may use $t in this way

<template>

<div>
  <span>{{$t('.title')}}</span>
</div>

</template>

<script>

export default {
  name: 'UserCard',
  vueT: true
}

</script>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published