vue-switch-lang

A small and easy-to-use component to switch between languages in a dropdown menu, created by Vue.js.
1,448
Install
npm install vue-switch-lang
Latest Version:0.4.0
Vue:2
License:ISC
Last Updated:Oct 25, 2024
Links: GitHub  ·  npm
Maintainer: aliafsah

vue-switch-lang

A small and easy-to-use component to switch between languages in a dropdown menu, created by Vue.js.

Demo

https://aliafsah1988.github.io/vue-switch-lang/

How to use

  1. Intall it with npm:
npm i vue-switch-lang
  1. You can use it:
  • Locally:
    In your parent component:
<template>
  <div class="home">
    <SwitchLang @changed="onChange" :initLang="initLang" :options="options" />
  </div>
</template>

<script>
import SwitchLang from "vue-switch-lang";

export default {
  components: {
    SwitchLang
  },
  methods: {
    onChange(lang) {
      // Do something
    }
  },
  data() {
    return {
      initLang: {
        title: "en",
        flag: "gb"
      },
      options: [
        {
          title: "en",
          flag: "gb"
        },
        {
          title: "de",
          flag: "de"
        },
        {
          title: "fa",
          flag: "ir"
        }
      ]
    };
  }
};
</script>

<style>
.multiselect__option--selected {
  background-color: red;
}

.multiselect__option--highlight {
  background-color: green;
  background: green;
}
</style>
  • Gobally:
    In the file that you instantiate Vue (usually main.js):
import Vue from "vue";
import App from "./App.vue";
import SwitchLang from "vue-switch-lang";

Vue.component("SwitchLang");

new Vue({
  render: h => h(App)
}).$mount("#app");

For running the whole project in dev mode

  1. Go to the root of application and install packages with:
npm install
  1. Then run the application with
npm run serve
  1. If you want to build it:
npm run build

Dependencies

If you need a sample to create a multi language SPA with Vue.js with ability to change between right-to-left and left-to-right, please visit:
https://github.com/aliafsah1988/vue-multilang-sample

Related Packages

webcake-ui-kit

UI Kit for Vue 2 && 3 - Pure Options API

19,775 8
yn-components

Advanced and highly reusable Mobile UI Components built on Vue2 & You can define...

3,128 6
vue-login-test

Componete vue kt

708
tinymce-vue-2

A vue 2 component for TinyMCE

27,768 48
@zeit-ui/vue

A popular UI framework for Vue

4,030 704

Version History

Version Released Vue License
0.4.0 ^2.6.11 ISC
0.3.1 ^2.6.11 ISC
0.3.0 ^2.6.11 ISC
0.2.4 ^2.6.11 ISC
0.2.3 ^2.6.11 ISC