neetjn / v-localize

Simple localization plugin for the amazing Vue.js.

Home Page:https://neetjn.github.io/v-localize/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Examples needed?

matthew-dean opened this issue · comments

I don't see any examples in the readme of how to actually implement this in .vue files. How are elements labeled to be translated?

My apologies, this was an experimental plugin with Vue. I'll definitely go ahead and update the docs as soon as I finish reworking the plugin.

You can localize your elements using the directive v-localize. An example,

const localizations =
{
  en: {
    header: {
      title: 'Hello World!'
    },
    body: {
      content: 'Today is the 5th of May.'
    }
  },
  sp: {
    header: {
      title: 'Hola Mundo!'
    },
    body: {
      content: 'Hoy es el cinco de Mayo.'
    }
  }
};

Vue.use(VueLocalize, {
  lang_default: 'en',
  localizations: localizations,
  locale_default: '...'
}); // # install our plugin
<h1 v-localize="'header.title'"></h1>

We use innerHTML to modify the DOM, so you can include HTML in your localization map. Again, I apologize for the lack of documentation, I've been working on another project.

The new version will support localization with titles and other like attributes.

Version 1.0.3 released. If you have any questions, feel free to re-open. I've added more useful documentation into the README.