How to use the vue-i18n.prototype function in vue-i18n

To help you get started, we’ve selected a few vue-i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github presentator / presentator / packages / spa / src / i18n.js View on Github external
import ClientStorage from '@/utils/ClientStorage';

Vue.use(VueI18n);

export const supportedLanguages = {
    "en-US": "English",
    "bg-BG": "Български",
    "de-DE": "Deutsch",
    "nl-NL": "Nederlands",
    "pt-BR": "Português",
};

// Extend the internal `VueI18n._translate` method in order to
// populate the source language messages on runtime
const sourceMessages = {};
const i18nTranslate = VueI18n.prototype._translate;
VueI18n.prototype._translate = function (messages, locale, fallback, key, host, interpolateMode, args) {
    if (!sourceMessages[key]) {
        sourceMessages[key] = key;
    }

    return i18nTranslate.apply(this, arguments);
};

const defaultLanguage = Object.keys(supportedLanguages)[0];

const i18nMessages = {};
i18nMessages[defaultLanguage] = sourceMessages;

// Create VueI18n instance
export const i18n = new VueI18n({
    locale:         defaultLanguage,
github presentator / presentator / packages / spa / src / i18n.js View on Github external
Vue.use(VueI18n);

export const supportedLanguages = {
    "en-US": "English",
    "bg-BG": "Български",
    "de-DE": "Deutsch",
    "nl-NL": "Nederlands",
    "pt-BR": "Português",
};

// Extend the internal `VueI18n._translate` method in order to
// populate the source language messages on runtime
const sourceMessages = {};
const i18nTranslate = VueI18n.prototype._translate;
VueI18n.prototype._translate = function (messages, locale, fallback, key, host, interpolateMode, args) {
    if (!sourceMessages[key]) {
        sourceMessages[key] = key;
    }

    return i18nTranslate.apply(this, arguments);
};

const defaultLanguage = Object.keys(supportedLanguages)[0];

const i18nMessages = {};
i18nMessages[defaultLanguage] = sourceMessages;

// Create VueI18n instance
export const i18n = new VueI18n({
    locale:         defaultLanguage,
    fallbackLocale: defaultLanguage,

vue-i18n

Internationalization plugin for Vue.js

MIT
Latest version published 24 days ago

Package Health Score

95 / 100
Full package analysis