Giter VIP home page Giter VIP logo

vue-translations's Introduction

VueJs Translations :shipit:

Hello everybody! I'm glad to present you a library to support the translations in your Vue project.

This translations component is very similar to Laravel Translations. You can setup inline params in your locale if needed.

Installation is very simple, in a few steps:

npm i vue-translations

You need to setup locale file for yourself.

// locales.js
export default {
    en: {
        home: {
            header: 'My best project ever',
        },
    },
    ru: {
        home: {
            header: 'Мой лучший проект в жизни',
        },
    },
};
import VueTranslation from 'vue-translations'
import locales from './locales.js';

Vue.use(VueTranslations);

new Vue({
    mounted() {
        // setup from one method
        this.$translations.setup('en', locales);
        // another methods:
        // change current language
        this.$translations.setLang('en');
        // load locales
        this.$translations.load(locales);
    },
    render: (h) => h,
});

Use it in your projects is easy!

<template>
    <div v-text="__t('home.header')" />
</template>

Inline params

Into your locale file

en: {
        home: {
            header: 'My best project - :name',
        },
    },
},

Into your application

<div v-text="__t('home.header', { name: 'Project' })" />
// output: My best project - Project

vue-translations's People

Contributors

owl1n avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.