0.0.5 • Published 6 years ago

vue-routes-i18n-generator v0.0.5

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

vue-routes-i18n-generator

Simple utility function that helps to handle multiple language routes through some aliases.

Installation

$ npm install vue-rotues-i18n-generator

Usage

import Router from 'vue-router'
import { generateRoutes } from 'vue-rotues-i18n-generator'

import Homepage from '@/containers/Homepage'
import Contacts from '@/containers/Contacts'

const DEFAULT_LOCALE = 'en'

const routes = [
  {
    paths: ['/it', '/en', '/fr', '/de'],
    name: 'homepage',
    component: Homepage
  },
  {
    paths: ['/it/contatti', '/en/contacts', '/fr/contacts', '/de/kontakte'],
    name: 'contacts',
    component: Contacts
  }
]

export default new Router({
  mode: 'history',
  scrollBehavior () {
    return { x: 0, y: 0 }
  },
  routes: [
    ...generateRoutes(routes),
    {
      path: '/*',
      redirect: {
        path: `/${DEFAULT_LOCALE}`
      }
    },
  ]
});

test

npm run test

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.1

6 years ago