V-Localize
V-Localize is a very simple localization plugin for Vue.js. Your localizations will be available anywhere in your web application wrapped in a Vue instance.
Support
Chome | Edge | Firefox | Opera | Safari |
---|---|---|---|---|
4.0+ ✔ | ✔ | 3.5+ ✔ | 10.50+ ✔ | 4.0+ ✔ |
V-Localize was developed using Vue.js 2.x, support for previous versions is not available.
Usage
To install via Bower, simply do the following:
To install via NPM:
For a quick start using jsdelivr:
Installing the plugin is then as simple as:
Once your Vue app has been instantiated, the language can be changed by calling $locale(args*)
from your Vue instance or virtual node.
You can specify your localizations like so:
Alternatively, you can get your current localization by calling $locale()
without specifying a language.
For fetching a specific locale item programatically within a component method:
Configuration
The plugin takes 5 options,
debug
: If enabled, will spit warnings and errors to console.
default
: Default language key to target if not set already.
available
: List of available localizations, can optionally specify locale options. ex;
fallback
: Default text to show if localization for current language not found. If not specified, will default to'N/A'
.
webStore
: If the Vue instance is accessed within a web context and optionwebStore
is enabled, plugin will store the locale in local storage for the next visit.
localizations
: JSON object for localizations.
Locale Options
Locale configuration currently supports the following options,
orientation
: Text direction of target element, useful for orientation of script languages.
font.family
: Font family to change to. Re: https://www.w3schools.com/jsref/prop_style_fontfamily.asp
font.size
: Font size to scale to. Re: https://www.w3schools.com/jsref/prop_style_fontsize.asp