You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vue-simple-translate

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-simple-translate

Serve json_encoded translation-arrays from html to vue.

1.0.1
latest
npmnpm
Version published
Maintainers
1
Created
Source

vue-simple-translate

Serve json_encoded translation-arrays from html to vue.

Installation

Install package

npm install vue-simple-translate --save

Setup

import VueSimpleTranslate from 'vue-simple-translate'
Vue.use(VueSimpleTranslate)

Usage

Add translations from HTML

Simple JSON

<div v-translate="{foo: 'bar'}">...</div>

With multidimensional JSON

<div v-translate="{foo: 'bar', user: {name: 'FOO', email: 'foo@bar.com'}}">...</div>
Namespace your translations

To namespace the translations, you can simply add the namepsace as directive-argument

<div v-translate:awesome="{foo: 'bar'}">...</div>

Getting translations

To access the translations you can simply use the $trans-method.

this.$trans('foo')
this.$trans('user.name')

Or in HTML

<div>
    {{ this.$trans('foo') }}
</div>

Use with laravel

To integrate the translation-files from laravel simply use the laravel trans-helper and add it json_encoded

<div v-translate:users="{{ json_encode(trans('users')) }}">

FAQs

Package last updated on 02 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts