Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex-i18n

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex-i18n - npm Package Compare versions

Comparing version 1.10.5 to 1.10.7

test/simple.html

38

dist/vuex-i18n.cjs.js

@@ -361,6 +361,8 @@ 'use strict';

// merge default options with user supplied options
var mergedConfig = Object.assign({
config = Object.assign({
warnings: true,
moduleName: 'i18n',
identifiers: ['{', '}'],
preserveState: false,
translateFilterName: 'translate',
onTranslationNotFound: function onTranslationNotFound() {}

@@ -370,8 +372,9 @@ }, config);

// define module name and identifiers as constants to prevent any changes
var moduleName = mergedConfig.moduleName;
var identifiers = mergedConfig.identifiers;
var moduleName = config.moduleName;
var identifiers = config.identifiers;
var translateFilterName = config.translateFilterName;
// initialize the onTranslationNotFound function and make sure it is actually
// a function
var onTranslationNotFound = mergedConfig.onTranslationNotFound;
var onTranslationNotFound = config.onTranslationNotFound;
if (typeof onTranslationNotFound !== 'function') {

@@ -384,3 +387,3 @@ console.error('i18n: i18n config option onTranslationNotFound must be a function');

// preserveState can be used via configuration if server side rendering is used
store.registerModule(moduleName, i18nVuexModule, { preserveState: mergedConfig.preserveState });
store.registerModule(moduleName, i18nVuexModule, { preserveState: config.preserveState });

@@ -406,5 +409,4 @@ // check if the plugin was correctly initialized

}
// initialize the replacement function
var render = renderFn(identifiers);
var render = renderFn(identifiers, config.warnings);

@@ -470,3 +472,3 @@ // get localized string from store. note that we pass the arguments passed

if (!locale) {
console.warn('i18n: i18n locale is not set when trying to access translations:', key);
if (config.warnings) console.warn('i18n: i18n locale is not set when trying to access translations:', key);
return defaultValue;

@@ -630,3 +632,3 @@ }

var phaseOutExistsFn = function phaseOutExistsFn(locale) {
console.warn('i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exatly the same functionality.');
if (config.warnings) console.warn('i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exactly the same functionality.');
return checkLocaleExists(locale);

@@ -682,3 +684,3 @@ };

// register a filter function for translations
Vue.filter('translate', translate);
Vue.filter(translateFilterName, translate);
};

@@ -692,3 +694,5 @@

var renderFn = function renderFn(identifiers) {
var warnings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (identifiers == null || identifiers.length != 2) {

@@ -699,9 +703,7 @@ console.warn('i18n: You must specify the start and end character identifying variable substitutions');

// construct a regular expression ot find variable substitutions, i.e. {test}
var matcher = new RegExp('' + identifiers[0] + '\\w+' + identifiers[1], 'g');
var matcher = new RegExp('' + identifiers[0] + '{1}\\w.+?' + identifiers[1] + '{1}', 'g');
// define the replacement function
var replace = function replace(translation, replacements) {
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// check if the object has a replace property

@@ -722,3 +724,3 @@ if (!translation.replace) {

// warn user that the placeholder has not been found
if (warn === true) {
if (warnings) {
console.group ? console.group('i18n: Not all placeholders found') : console.warn('i18n: Not all placeholders found');

@@ -767,3 +769,3 @@ console.warn('Text:', translation);

if (pluralizationType !== 'number') {
console.warn('i18n: pluralization is not a number');
if (warnings) console.warn('i18n: pluralization is not a number');
return resolvePlaceholders();

@@ -794,3 +796,5 @@ }

if (typeof pluralizations[index] === 'undefined') {
console.warn('i18n: pluralization not provided in locale', translation, locale, index);
if (warnings) {
console.warn('i18n: pluralization not provided in locale', translation, locale, index);
}

@@ -814,4 +818,2 @@ // return the first element of the pluralization by default

// import the vuex module for localization
// import the corresponding plugin for vue
// export both modules as one file

@@ -818,0 +820,0 @@ var index = {

@@ -359,6 +359,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

// merge default options with user supplied options
var mergedConfig = Object.assign({
config = Object.assign({
warnings: true,
moduleName: 'i18n',
identifiers: ['{', '}'],
preserveState: false,
translateFilterName: 'translate',
onTranslationNotFound: function onTranslationNotFound() {}

@@ -368,8 +370,9 @@ }, config);

// define module name and identifiers as constants to prevent any changes
var moduleName = mergedConfig.moduleName;
var identifiers = mergedConfig.identifiers;
var moduleName = config.moduleName;
var identifiers = config.identifiers;
var translateFilterName = config.translateFilterName;
// initialize the onTranslationNotFound function and make sure it is actually
// a function
var onTranslationNotFound = mergedConfig.onTranslationNotFound;
var onTranslationNotFound = config.onTranslationNotFound;
if (typeof onTranslationNotFound !== 'function') {

@@ -382,3 +385,3 @@ console.error('i18n: i18n config option onTranslationNotFound must be a function');

// preserveState can be used via configuration if server side rendering is used
store.registerModule(moduleName, i18nVuexModule, { preserveState: mergedConfig.preserveState });
store.registerModule(moduleName, i18nVuexModule, { preserveState: config.preserveState });

@@ -404,5 +407,4 @@ // check if the plugin was correctly initialized

}
// initialize the replacement function
var render = renderFn(identifiers);
var render = renderFn(identifiers, config.warnings);

@@ -468,3 +470,3 @@ // get localized string from store. note that we pass the arguments passed

if (!locale) {
console.warn('i18n: i18n locale is not set when trying to access translations:', key);
if (config.warnings) console.warn('i18n: i18n locale is not set when trying to access translations:', key);
return defaultValue;

@@ -628,3 +630,3 @@ }

var phaseOutExistsFn = function phaseOutExistsFn(locale) {
console.warn('i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exatly the same functionality.');
if (config.warnings) console.warn('i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exactly the same functionality.');
return checkLocaleExists(locale);

@@ -680,3 +682,3 @@ };

// register a filter function for translations
Vue.filter('translate', translate);
Vue.filter(translateFilterName, translate);
};

@@ -690,3 +692,5 @@

var renderFn = function renderFn(identifiers) {
var warnings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (identifiers == null || identifiers.length != 2) {

@@ -697,9 +701,7 @@ console.warn('i18n: You must specify the start and end character identifying variable substitutions');

// construct a regular expression ot find variable substitutions, i.e. {test}
var matcher = new RegExp('' + identifiers[0] + '\\w+' + identifiers[1], 'g');
var matcher = new RegExp('' + identifiers[0] + '{1}\\w.+?' + identifiers[1] + '{1}', 'g');
// define the replacement function
var replace = function replace(translation, replacements) {
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// check if the object has a replace property

@@ -720,3 +722,3 @@ if (!translation.replace) {

// warn user that the placeholder has not been found
if (warn === true) {
if (warnings) {
console.group ? console.group('i18n: Not all placeholders found') : console.warn('i18n: Not all placeholders found');

@@ -765,3 +767,3 @@ console.warn('Text:', translation);

if (pluralizationType !== 'number') {
console.warn('i18n: pluralization is not a number');
if (warnings) console.warn('i18n: pluralization is not a number');
return resolvePlaceholders();

@@ -792,3 +794,5 @@ }

if (typeof pluralizations[index] === 'undefined') {
console.warn('i18n: pluralization not provided in locale', translation, locale, index);
if (warnings) {
console.warn('i18n: pluralization not provided in locale', translation, locale, index);
}

@@ -812,4 +816,2 @@ // return the first element of the pluralization by default

// import the vuex module for localization
// import the corresponding plugin for vue
// export both modules as one file

@@ -816,0 +818,0 @@ var index = {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.vuexI18n=t()}(this,function(){"use strict";function e(e){return!!e&&Array===e.constructor}function t(e){return!!e&&Array===e.constructor}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a={namespaced:!0,state:{locale:null,fallback:null,translations:{}},mutations:{SET_LOCALE:function e(t,n){t.locale=n.locale},ADD_LOCALE:function e(t,n){var a=r(n.translations);if(t.translations.hasOwnProperty(n.locale)){var o=t.translations[n.locale];t.translations[n.locale]=Object.assign({},o,a)}else t.translations[n.locale]=a;try{t.translations.__ob__&&t.translations.__ob__.dep.notify()}catch(e){}},REPLACE_LOCALE:function e(t,n){var a=r(n.translations);t.translations[n.locale]=a;try{t.translations.__ob__&&t.translations.__ob__.dep.notify()}catch(e){}},REMOVE_LOCALE:function e(t,n){if(t.translations.hasOwnProperty(n.locale)){t.locale===n.locale&&(t.locale=null);var a=Object.assign({},t.translations);delete a[n.locale],t.translations=a}},SET_FALLBACK_LOCALE:function e(t,n){t.fallback=n.locale}},actions:{setLocale:function e(t,n){t.commit({type:"SET_LOCALE",locale:n.locale})},addLocale:function e(t,n){t.commit({type:"ADD_LOCALE",locale:n.locale,translations:n.translations})},replaceLocale:function e(t,n){t.commit({type:"REPLACE_LOCALE",locale:n.locale,translations:n.translations})},removeLocale:function e(t,n){t.commit({type:"REMOVE_LOCALE",locale:n.locale,translations:n.translations})},setFallbackLocale:function e(t,n){t.commit({type:"SET_FALLBACK_LOCALE",locale:n.locale})}}},r=function t(a){var r={};for(var o in a)if(a.hasOwnProperty(o)){var s=n(a[o]);if(e(a[o])){for(var l=a[o].length,c=0;c<l;c++){var i=n(a[o][c]);if("string"!==i){console.warn("i18n:","currently only arrays of strings are fully supported",a[o]);break}}r[o]=a[o]}else if("object"==s&&null!==s){var u=t(a[o]);for(var f in u)u.hasOwnProperty(f)&&(r[o+"."+f]=u[f])}else r[o]=a[o]}return r},o={getTranslationIndex:function e(t,n){switch(t){case"ay":case"bo":case"cgg":case"dz":case"fa":case"id":case"ja":case"jbo":case"ka":case"kk":case"km":case"ko":case"ky":case"lo":case"ms":case"my":case"sah":case"su":case"th":case"tt":case"ug":case"vi":case"wo":case"zh":return 0;case"is":return n%10!=1||n%100==11?1:0;case"jv":return 0!==n?1:0;case"mk":return 1===n||n%10==1?0:1;case"ach":case"ak":case"am":case"arn":case"br":case"fil":case"fr":case"gun":case"ln":case"mfe":case"mg":case"mi":case"oc":case"pt_BR":case"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return n>1?1:0;case"lv":return n%10==1&&n%100!=11?0:0!==n?1:2;case"lt":return n%10==1&&n%100!=11?0:n%10>=2&&(n%100<10||n%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return n%10==1&&n%100!=11?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2;case"mnk":return 0===n?0:1===n?1:2;case"ro":return 1===n?0:0===n||n%100>0&&n%100<20?1:2;case"pl":return 1===n?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2;case"cs":case"sk":return 1===n?0:n>=2&&n<=4?1:2;case"csb":return 1===n?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2;case"sl":return n%100==1?0:n%100==2?1:n%100==3||n%100==4?2:3;case"mt":return 1===n?0:0===n||n%100>1&&n%100<11?1:n%100>10&&n%100<20?2:3;case"gd":return 1===n||11===n?0:2===n||12===n?1:n>2&&n<20?2:3;case"cy":return 1===n?0:2===n?1:8!==n&&11!==n?2:3;case"kw":return 1===n?0:2===n?1:3===n?2:3;case"ga":return 1===n?0:2===n?1:n>2&&n<7?2:n>6&&n<11?3:4;case"ar":return 0===n?0:1===n?1:2===n?2:n%100>=3&&n%100<=10?3:n%100>=11?4:5;default:return 1!==n?1:0}}},s={};s.install=function e(t,n,r){"string"!=typeof arguments[2]&&"string"!=typeof arguments[3]||(console.warn("i18n: Registering the plugin vuex-i18n with a string for `moduleName` or `identifiers` is deprecated. Use a configuration object instead.","https://github.com/dkfbasel/vuex-i18n#setup"),r={moduleName:arguments[2],identifiers:arguments[3]});var o=Object.assign({moduleName:"i18n",identifiers:["{","}"],preserveState:!1,onTranslationNotFound:function e(){}},r),s=o.moduleName,c=o.identifiers,i=o.onTranslationNotFound;if("function"!=typeof i&&(console.error("i18n: i18n config option onTranslationNotFound must be a function"),i=function e(){}),n.registerModule(s,a,{preserveState:o.preserveState}),!1===n.state.hasOwnProperty(s))return console.error("i18n: i18n vuex module is not correctly initialized. Please check the module name:",s),t.prototype.$i18n=function(e){return e},t.prototype.$getLanguage=function(){return null},void(t.prototype.$setLanguage=function(){console.error("i18n: i18n vuex module is not correctly initialized")});var u=l(c),f=function e(){var t=n.state[s].locale;return p.apply(void 0,[t].concat(Array.prototype.slice.call(arguments)))},p=function e(t){var a=arguments,r="",o="",l={},c=null,f=a.length;if(f>=3&&"string"==typeof a[2]?(r=a[1],o=a[2],f>3&&(l=a[3]),f>4&&(c=a[4])):(r=a[1],o=r,f>2&&(l=a[2]),f>3&&(c=a[3])),!t)return console.warn("i18n: i18n locale is not set when trying to access translations:",r),o;var p=n.state[s].translations,d=n.state[s].fallback,y=t.split("-"),h=!0;if(!1===p.hasOwnProperty(t)?h=!1:!1===p[t].hasOwnProperty(r)&&(h=!1),!0===h)return u(t,p[t][r],l,c);if(y.length>1&&!0===p.hasOwnProperty(y[0])&&!0===p[y[0]].hasOwnProperty(r))return u(y[0],p[y[0]][r],l,c);var m=i(t,r,o);return m&&Promise.resolve(m).then(function(e){var n={};n[r]=e,g(t,n)}),!1===p.hasOwnProperty(d)?u(t,o,l,c):!1===p[d].hasOwnProperty(r)?u(d,o,l,c):u(t,p[d][r],l,c)},d=function e(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fallback",r=n.state[s].locale,o=n.state[s].fallback,l=n.state[s].translations;if(l.hasOwnProperty(r)&&l[r].hasOwnProperty(t))return!0;if("strict"==a)return!1;var c=r.split("-");return!!(c.length>1&&l.hasOwnProperty(c[0])&&l[c[0]].hasOwnProperty(t))||"locale"!=a&&!(!l.hasOwnProperty(o)||!l[o].hasOwnProperty(t))},y=function e(t){n.dispatch({type:s+"/setFallbackLocale",locale:t})},h=function e(t){n.dispatch({type:s+"/setLocale",locale:t})},m=function e(){return n.state[s].locale},v=function e(){return Object.keys(n.state[s].translations)},g=function e(t,a){return n.dispatch({type:s+"/addLocale",locale:t,translations:a})},b=function e(t,a){return n.dispatch({type:s+"/replaceLocale",locale:t,translations:a})},L=function e(t){n.state[s].translations.hasOwnProperty(t)&&n.dispatch({type:s+"/removeLocale",locale:t})},w=function e(t){return console.warn("i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exatly the same functionality."),O(t)},O=function e(t){return n.state[s].translations.hasOwnProperty(t)};t.prototype.$i18n={locale:m,locales:v,set:h,add:g,replace:b,remove:L,fallback:y,localeExists:O,keyExists:d,translate:f,translateIn:p,exists:w},t.i18n={locale:m,locales:v,set:h,add:g,replace:b,remove:L,fallback:y,translate:f,translateIn:p,localeExists:O,keyExists:d,exists:w},t.prototype.$t=f,t.prototype.$tlang=p,t.filter("translate",f)};var l=function e(a){null!=a&&2==a.length||console.warn("i18n: You must specify the start and end character identifying variable substitutions");var r=new RegExp(a[0]+"\\w+"+a[1],"g"),s=function e(t,n){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.replace?t.replace(r,function(e){var r=e.replace(a[0],"").replace(a[1],"");return void 0!==n[r]?n[r]:(!0===o&&(console.group?console.group("i18n: Not all placeholders found"):console.warn("i18n: Not all placeholders found"),console.warn("Text:",t),console.warn("Placeholder:",e),console.groupEnd&&console.groupEnd()),e)}):t};return function e(a,r){var l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=void 0===r?"undefined":n(r),u=void 0===c?"undefined":n(c),f=function e(){return t(r)?r.map(function(e){return s(e,l,!1)}):"string"===i?s(r,l,!0):void 0};if(null===c)return f();if("number"!==u)return console.warn("i18n: pluralization is not a number"),f();var p=f(),d=null;d=t(p)&&p.length>0?p:p.split(":::");var y=o.getTranslationIndex(a,c);return void 0===d[y]?(console.warn("i18n: pluralization not provided in locale",r,a,y),d[0].trim()):d[y].trim()}};return{store:a,plugin:s}});
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):global.vuexI18n=factory()}(this,function(){"use strict";function isArray(obj){return!!obj&&Array===obj.constructor}function isArray$1(obj){return!!obj&&Array===obj.constructor}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},i18nVuexModule={namespaced:!0,state:{locale:null,fallback:null,translations:{}},mutations:{SET_LOCALE:function(state,payload){state.locale=payload.locale},ADD_LOCALE:function(state,payload){var translations=flattenTranslations(payload.translations);if(state.translations.hasOwnProperty(payload.locale)){var existingTranslations=state.translations[payload.locale];state.translations[payload.locale]=Object.assign({},existingTranslations,translations)}else state.translations[payload.locale]=translations;try{state.translations.__ob__&&state.translations.__ob__.dep.notify()}catch(ex){}},REPLACE_LOCALE:function(state,payload){var translations=flattenTranslations(payload.translations);state.translations[payload.locale]=translations;try{state.translations.__ob__&&state.translations.__ob__.dep.notify()}catch(ex){}},REMOVE_LOCALE:function(state,payload){if(state.translations.hasOwnProperty(payload.locale)){state.locale===payload.locale&&(state.locale=null);var translationCopy=Object.assign({},state.translations);delete translationCopy[payload.locale],state.translations=translationCopy}},SET_FALLBACK_LOCALE:function(state,payload){state.fallback=payload.locale}},actions:{setLocale:function(context,payload){context.commit({type:"SET_LOCALE",locale:payload.locale})},addLocale:function(context,payload){context.commit({type:"ADD_LOCALE",locale:payload.locale,translations:payload.translations})},replaceLocale:function(context,payload){context.commit({type:"REPLACE_LOCALE",locale:payload.locale,translations:payload.translations})},removeLocale:function(context,payload){context.commit({type:"REMOVE_LOCALE",locale:payload.locale,translations:payload.translations})},setFallbackLocale:function(context,payload){context.commit({type:"SET_FALLBACK_LOCALE",locale:payload.locale})}}},flattenTranslations=function flattenTranslations(translations){var toReturn={};for(var i in translations)if(translations.hasOwnProperty(i)){var objType=_typeof(translations[i]);if(isArray(translations[i])){for(var count=translations[i].length,index=0;index<count;index++)if("string"!==_typeof(translations[i][index])){console.warn("i18n:","currently only arrays of strings are fully supported",translations[i]);break}toReturn[i]=translations[i]}else if("object"==objType&&null!==objType){var flatObject=flattenTranslations(translations[i]);for(var x in flatObject)flatObject.hasOwnProperty(x)&&(toReturn[i+"."+x]=flatObject[x])}else toReturn[i]=translations[i]}return toReturn},plurals={getTranslationIndex:function(languageCode,n){switch(languageCode){case"ay":case"bo":case"cgg":case"dz":case"fa":case"id":case"ja":case"jbo":case"ka":case"kk":case"km":case"ko":case"ky":case"lo":case"ms":case"my":case"sah":case"su":case"th":case"tt":case"ug":case"vi":case"wo":case"zh":return 0;case"is":return n%10!=1||n%100==11?1:0;case"jv":return 0!==n?1:0;case"mk":return 1===n||n%10==1?0:1;case"ach":case"ak":case"am":case"arn":case"br":case"fil":case"fr":case"gun":case"ln":case"mfe":case"mg":case"mi":case"oc":case"pt_BR":case"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return n>1?1:0;case"lv":return n%10==1&&n%100!=11?0:0!==n?1:2;case"lt":return n%10==1&&n%100!=11?0:n%10>=2&&(n%100<10||n%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return n%10==1&&n%100!=11?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2;case"mnk":return 0===n?0:1===n?1:2;case"ro":return 1===n?0:0===n||n%100>0&&n%100<20?1:2;case"pl":return 1===n?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2;case"cs":case"sk":return 1===n?0:n>=2&&n<=4?1:2;case"csb":return 1===n?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2;case"sl":return n%100==1?0:n%100==2?1:n%100==3||n%100==4?2:3;case"mt":return 1===n?0:0===n||n%100>1&&n%100<11?1:n%100>10&&n%100<20?2:3;case"gd":return 1===n||11===n?0:2===n||12===n?1:n>2&&n<20?2:3;case"cy":return 1===n?0:2===n?1:8!==n&&11!==n?2:3;case"kw":return 1===n?0:2===n?1:3===n?2:3;case"ga":return 1===n?0:2===n?1:n>2&&n<7?2:n>6&&n<11?3:4;case"ar":return 0===n?0:1===n?1:2===n?2:n%100>=3&&n%100<=10?3:n%100>=11?4:5;default:return 1!==n?1:0}}},VuexI18nPlugin={};VuexI18nPlugin.install=function(Vue,store,config){"string"!=typeof arguments[2]&&"string"!=typeof arguments[3]||(console.warn("i18n: Registering the plugin vuex-i18n with a string for `moduleName` or `identifiers` is deprecated. Use a configuration object instead.","https://github.com/dkfbasel/vuex-i18n#setup"),config={moduleName:arguments[2],identifiers:arguments[3]});var moduleName=(config=Object.assign({warnings:!0,moduleName:"i18n",identifiers:["{","}"],preserveState:!1,translateFilterName:"translate",onTranslationNotFound:function(){}},config)).moduleName,identifiers=config.identifiers,translateFilterName=config.translateFilterName,onTranslationNotFound=config.onTranslationNotFound;if("function"!=typeof onTranslationNotFound&&(console.error("i18n: i18n config option onTranslationNotFound must be a function"),onTranslationNotFound=function(){}),store.registerModule(moduleName,i18nVuexModule,{preserveState:config.preserveState}),!1===store.state.hasOwnProperty(moduleName))return console.error("i18n: i18n vuex module is not correctly initialized. Please check the module name:",moduleName),Vue.prototype.$i18n=function(key){return key},Vue.prototype.$getLanguage=function(){return null},void(Vue.prototype.$setLanguage=function(){console.error("i18n: i18n vuex module is not correctly initialized")});var render=renderFn(identifiers,config.warnings),translate=function(){var locale=store.state[moduleName].locale;return translateInLanguage.apply(void 0,[locale].concat(Array.prototype.slice.call(arguments)))},translateInLanguage=function(locale){var args=arguments,key="",defaultValue="",options={},pluralization=null,count=args.length;if(count>=3&&"string"==typeof args[2]?(key=args[1],defaultValue=args[2],count>3&&(options=args[3]),count>4&&(pluralization=args[4])):(defaultValue=key=args[1],count>2&&(options=args[2]),count>3&&(pluralization=args[3])),!locale)return config.warnings&&console.warn("i18n: i18n locale is not set when trying to access translations:",key),defaultValue;var translations=store.state[moduleName].translations,fallback=store.state[moduleName].fallback,localeRegional=locale.split("-"),translationExists=!0;if(!1===translations.hasOwnProperty(locale)?translationExists=!1:!1===translations[locale].hasOwnProperty(key)&&(translationExists=!1),!0===translationExists)return render(locale,translations[locale][key],options,pluralization);if(localeRegional.length>1&&!0===translations.hasOwnProperty(localeRegional[0])&&!0===translations[localeRegional[0]].hasOwnProperty(key))return render(localeRegional[0],translations[localeRegional[0]][key],options,pluralization);var asyncTranslation=onTranslationNotFound(locale,key,defaultValue);return asyncTranslation&&Promise.resolve(asyncTranslation).then(function(value){var additionalTranslations={};additionalTranslations[key]=value,addLocale(locale,additionalTranslations)}),!1===translations.hasOwnProperty(fallback)?render(locale,defaultValue,options,pluralization):!1===translations[fallback].hasOwnProperty(key)?render(fallback,defaultValue,options,pluralization):render(locale,translations[fallback][key],options,pluralization)},checkKeyExists=function(key){var scope=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fallback",locale=store.state[moduleName].locale,fallback=store.state[moduleName].fallback,translations=store.state[moduleName].translations;if(translations.hasOwnProperty(locale)&&translations[locale].hasOwnProperty(key))return!0;if("strict"==scope)return!1;var localeRegional=locale.split("-");return!!(localeRegional.length>1&&translations.hasOwnProperty(localeRegional[0])&&translations[localeRegional[0]].hasOwnProperty(key))||"locale"!=scope&&!(!translations.hasOwnProperty(fallback)||!translations[fallback].hasOwnProperty(key))},setFallbackLocale=function(locale){store.dispatch({type:moduleName+"/setFallbackLocale",locale:locale})},setLocale=function(locale){store.dispatch({type:moduleName+"/setLocale",locale:locale})},getLocale=function(){return store.state[moduleName].locale},getLocales=function(){return Object.keys(store.state[moduleName].translations)},addLocale=function(locale,translations){return store.dispatch({type:moduleName+"/addLocale",locale:locale,translations:translations})},replaceLocale=function(locale,translations){return store.dispatch({type:moduleName+"/replaceLocale",locale:locale,translations:translations})},removeLocale=function(locale){store.state[moduleName].translations.hasOwnProperty(locale)&&store.dispatch({type:moduleName+"/removeLocale",locale:locale})},phaseOutExistsFn=function(locale){return config.warnings&&console.warn("i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exactly the same functionality."),checkLocaleExists(locale)},checkLocaleExists=function(locale){return store.state[moduleName].translations.hasOwnProperty(locale)};Vue.prototype.$i18n={locale:getLocale,locales:getLocales,set:setLocale,add:addLocale,replace:replaceLocale,remove:removeLocale,fallback:setFallbackLocale,localeExists:checkLocaleExists,keyExists:checkKeyExists,translate:translate,translateIn:translateInLanguage,exists:phaseOutExistsFn},Vue.i18n={locale:getLocale,locales:getLocales,set:setLocale,add:addLocale,replace:replaceLocale,remove:removeLocale,fallback:setFallbackLocale,translate:translate,translateIn:translateInLanguage,localeExists:checkLocaleExists,keyExists:checkKeyExists,exists:phaseOutExistsFn},Vue.prototype.$t=translate,Vue.prototype.$tlang=translateInLanguage,Vue.filter(translateFilterName,translate)};var renderFn=function(identifiers){var warnings=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];null!=identifiers&&2==identifiers.length||console.warn("i18n: You must specify the start and end character identifying variable substitutions");var matcher=new RegExp(identifiers[0]+"{1}\\w.+?"+identifiers[1]+"{1}","g"),replace=function(translation,replacements){return translation.replace?translation.replace(matcher,function(placeholder){var key=placeholder.replace(identifiers[0],"").replace(identifiers[1],"");return void 0!==replacements[key]?replacements[key]:(warnings&&(console.group?console.group("i18n: Not all placeholders found"):console.warn("i18n: Not all placeholders found"),console.warn("Text:",translation),console.warn("Placeholder:",placeholder),console.groupEnd&&console.groupEnd()),placeholder)}):translation};return function(locale,translation){var replacements=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},pluralization=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,objType=void 0===translation?"undefined":_typeof(translation),pluralizationType=void 0===pluralization?"undefined":_typeof(pluralization),resolvePlaceholders=function(){return isArray$1(translation)?translation.map(function(item){return replace(item,replacements)}):"string"===objType?replace(translation,replacements):void 0};if(null===pluralization)return resolvePlaceholders();if("number"!==pluralizationType)return warnings&&console.warn("i18n: pluralization is not a number"),resolvePlaceholders();var resolvedTranslation=resolvePlaceholders(),pluralizations=null;pluralizations=isArray$1(resolvedTranslation)&&resolvedTranslation.length>0?resolvedTranslation:resolvedTranslation.split(":::");var index=plurals.getTranslationIndex(locale,pluralization);return void 0===pluralizations[index]?(warnings&&console.warn("i18n: pluralization not provided in locale",translation,locale,index),pluralizations[0].trim()):pluralizations[index].trim()}};return{store:i18nVuexModule,plugin:VuexI18nPlugin}});
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.vuexI18n = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.vuexI18n = factory());
}(this, (function () { 'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
/* vuex-i18n-store defines a vuex module to store locale translations. Make sure
** to also include the file vuex-i18n.js to enable easy access to localized
** strings in your vue components.
*/
/* vuex-i18n-store defines a vuex module to store locale translations. Make sure
** to also include the file vuex-i18n.js to enable easy access to localized
** strings in your vue components.
*/
// define a simple vuex module to handle locale translations
var i18nVuexModule = {
namespaced: true,
state: {
locale: null,
fallback: null,
translations: {}
},
mutations: {
// define a simple vuex module to handle locale translations
var i18nVuexModule = {
namespaced: true,
state: {
locale: null,
fallback: null,
translations: {}
},
mutations: {
// set the current locale
SET_LOCALE: function SET_LOCALE(state, payload) {
state.locale = payload.locale;
},
// set the current locale
SET_LOCALE: function SET_LOCALE(state, payload) {
state.locale = payload.locale;
},
// add a new locale
ADD_LOCALE: function ADD_LOCALE(state, payload) {
// add a new locale
ADD_LOCALE: function ADD_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
if (state.translations.hasOwnProperty(payload.locale)) {
// get the existing translations
var existingTranslations = state.translations[payload.locale];
// merge the translations
state.translations[payload.locale] = Object.assign({}, existingTranslations, translations);
} else {
// just set the locale if it does not yet exist
state.translations[payload.locale] = translations;
}
if (state.translations.hasOwnProperty(payload.locale)) {
// get the existing translations
var existingTranslations = state.translations[payload.locale];
// merge the translations
state.translations[payload.locale] = Object.assign({}, existingTranslations, translations);
} else {
// just set the locale if it does not yet exist
state.translations[payload.locale] = translations;
}
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// replace existing locale information with new translations
REPLACE_LOCALE: function REPLACE_LOCALE(state, payload) {
// replace existing locale information with new translations
REPLACE_LOCALE: function REPLACE_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
// replace the translations entirely
state.translations[payload.locale] = translations;
// replace the translations entirely
state.translations[payload.locale] = translations;
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// remove a locale from the store
REMOVE_LOCALE: function REMOVE_LOCALE(state, payload) {
// remove a locale from the store
REMOVE_LOCALE: function REMOVE_LOCALE(state, payload) {
// check if the given locale is present in the state
if (state.translations.hasOwnProperty(payload.locale)) {
// check if the given locale is present in the state
if (state.translations.hasOwnProperty(payload.locale)) {
// check if the current locale is the given locale to remvoe
if (state.locale === payload.locale) {
// reset the current locale
state.locale = null;
}
// check if the current locale is the given locale to remvoe
if (state.locale === payload.locale) {
// reset the current locale
state.locale = null;
}
// create a copy of the translations object
var translationCopy = Object.assign({}, state.translations);
// create a copy of the translations object
var translationCopy = Object.assign({}, state.translations);
// remove the given locale
delete translationCopy[payload.locale];
// remove the given locale
delete translationCopy[payload.locale];
// set the state to the new object
state.translations = translationCopy;
}
},
SET_FALLBACK_LOCALE: function SET_FALLBACK_LOCALE(state, payload) {
state.fallback = payload.locale;
}
},
actions: {
// set the state to the new object
state.translations = translationCopy;
}
},
SET_FALLBACK_LOCALE: function SET_FALLBACK_LOCALE(state, payload) {
state.fallback = payload.locale;
}
},
actions: {
// set the current locale
setLocale: function setLocale(context, payload) {
context.commit({
type: 'SET_LOCALE',
locale: payload.locale
});
},
// set the current locale
setLocale: function setLocale(context, payload) {
context.commit({
type: 'SET_LOCALE',
locale: payload.locale
});
},
// add or extend a locale with translations
addLocale: function addLocale(context, payload) {
context.commit({
type: 'ADD_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// add or extend a locale with translations
addLocale: function addLocale(context, payload) {
context.commit({
type: 'ADD_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// replace locale information
replaceLocale: function replaceLocale(context, payload) {
context.commit({
type: 'REPLACE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// replace locale information
replaceLocale: function replaceLocale(context, payload) {
context.commit({
type: 'REPLACE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// remove the given locale translations
removeLocale: function removeLocale(context, payload) {
context.commit({
type: 'REMOVE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
setFallbackLocale: function setFallbackLocale(context, payload) {
context.commit({
type: 'SET_FALLBACK_LOCALE',
locale: payload.locale
});
}
}
};
// remove the given locale translations
removeLocale: function removeLocale(context, payload) {
context.commit({
type: 'REMOVE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
setFallbackLocale: function setFallbackLocale(context, payload) {
context.commit({
type: 'SET_FALLBACK_LOCALE',
locale: payload.locale
});
}
}
};
// flattenTranslations will convert object trees for translations into a
// single-depth object tree
var flattenTranslations = function flattenTranslations(translations) {
// flattenTranslations will convert object trees for translations into a
// single-depth object tree
var flattenTranslations = function flattenTranslations(translations) {
var toReturn = {};
var toReturn = {};
for (var i in translations) {
for (var i in translations) {
// check if the property is present
if (!translations.hasOwnProperty(i)) {
continue;
}
// check if the property is present
if (!translations.hasOwnProperty(i)) {
continue;
}
// get the type of the property
var objType = _typeof(translations[i]);
// get the type of the property
var objType = _typeof(translations[i]);
// allow unflattened array of strings
if (isArray(translations[i])) {
// allow unflattened array of strings
if (isArray(translations[i])) {
var count = translations[i].length;
var count = translations[i].length;
for (var index = 0; index < count; index++) {
var itemType = _typeof(translations[i][index]);
for (var index = 0; index < count; index++) {
var itemType = _typeof(translations[i][index]);
if (itemType !== 'string') {
console.warn('i18n:', 'currently only arrays of strings are fully supported', translations[i]);
break;
}
}
if (itemType !== 'string') {
console.warn('i18n:', 'currently only arrays of strings are fully supported', translations[i]);
break;
}
}
toReturn[i] = translations[i];
} else if (objType == 'object' && objType !== null) {
toReturn[i] = translations[i];
} else if (objType == 'object' && objType !== null) {
var flatObject = flattenTranslations(translations[i]);
var flatObject = flattenTranslations(translations[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
toReturn[i + '.' + x] = flatObject[x];
}
} else {
toReturn[i] = translations[i];
}
}
return toReturn;
};
toReturn[i + '.' + x] = flatObject[x];
}
} else {
toReturn[i] = translations[i];
}
}
return toReturn;
};
// check if the given object is an array
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
// check if the given object is an array
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
var plurals = {
getTranslationIndex: function getTranslationIndex(languageCode, n) {
switch (languageCode) {
case 'ay': // Aymará
case 'bo': // Tibetan
case 'cgg': // Chiga
case 'dz': // Dzongkha
case 'fa': // Persian
case 'id': // Indonesian
case 'ja': // Japanese
case 'jbo': // Lojban
case 'ka': // Georgian
case 'kk': // Kazakh
case 'km': // Khmer
case 'ko': // Korean
case 'ky': // Kyrgyz
case 'lo': // Lao
case 'ms': // Malay
case 'my': // Burmese
case 'sah': // Yakut
case 'su': // Sundanese
case 'th': // Thai
case 'tt': // Tatar
case 'ug': // Uyghur
case 'vi': // Vietnamese
case 'wo': // Wolof
case 'zh':
// Chinese
// 1 form
return 0;
case 'is':
// Icelandic
// 2 forms
return n % 10 !== 1 || n % 100 === 11 ? 1 : 0;
case 'jv':
// Javanese
// 2 forms
return n !== 0 ? 1 : 0;
case 'mk':
// Macedonian
// 2 forms
return n === 1 || n % 10 === 1 ? 0 : 1;
case 'ach': // Acholi
case 'ak': // Akan
case 'am': // Amharic
case 'arn': // Mapudungun
case 'br': // Breton
case 'fil': // Filipino
case 'fr': // French
case 'gun': // Gun
case 'ln': // Lingala
case 'mfe': // Mauritian Creole
case 'mg': // Malagasy
case 'mi': // Maori
case 'oc': // Occitan
case 'pt_BR': // Brazilian Portuguese
case 'tg': // Tajik
case 'ti': // Tigrinya
case 'tr': // Turkish
case 'uz': // Uzbek
case 'wa': // Walloon
/* eslint-disable */
/* Disable "Duplicate case label" because there are 2 forms of Chinese plurals */
case 'zh':
// Chinese
/* eslint-enable */
// 2 forms
return n > 1 ? 1 : 0;
case 'lv':
// Latvian
// 3 forms
return n % 10 === 1 && n % 100 !== 11 ? 0 : n !== 0 ? 1 : 2;
case 'lt':
// Lithuanian
// 3 forms
return n % 10 === 1 && n % 100 !== 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'be': // Belarusian
case 'bs': // Bosnian
case 'hr': // Croatian
case 'ru': // Russian
case 'sr': // Serbian
case 'uk':
// Ukrainian
// 3 forms
return n % 10 === 1 && n % 100 !== 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'mnk':
// Mandinka
// 3 forms
return n === 0 ? 0 : n === 1 ? 1 : 2;
case 'ro':
// Romanian
// 3 forms
return n === 1 ? 0 : n === 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2;
case 'pl':
// Polish
// 3 forms
return n === 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'cs': // Czech
case 'sk':
// Slovak
// 3 forms
return n === 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2;
case 'csb':
// Kashubian
// 3 forms
return n === 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'sl':
// Slovenian
// 4 forms
return n % 100 === 1 ? 0 : n % 100 === 2 ? 1 : n % 100 === 3 || n % 100 === 4 ? 2 : 3;
case 'mt':
// Maltese
// 4 forms
return n === 1 ? 0 : n === 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3;
case 'gd':
// Scottish Gaelic
// 4 forms
return n === 1 || n === 11 ? 0 : n === 2 || n === 12 ? 1 : n > 2 && n < 20 ? 2 : 3;
case 'cy':
// Welsh
// 4 forms
return n === 1 ? 0 : n === 2 ? 1 : n !== 8 && n !== 11 ? 2 : 3;
case 'kw':
// Cornish
// 4 forms
return n === 1 ? 0 : n === 2 ? 1 : n === 3 ? 2 : 3;
case 'ga':
// Irish
// 5 forms
return n === 1 ? 0 : n === 2 ? 1 : n > 2 && n < 7 ? 2 : n > 6 && n < 11 ? 3 : 4;
case 'ar':
// Arabic
// 6 forms
return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
default:
// Everything else
return n !== 1 ? 1 : 0;
}
}
};
var plurals = {
getTranslationIndex: function getTranslationIndex(languageCode, n) {
switch (languageCode) {
case 'ay': // Aymará
case 'bo': // Tibetan
case 'cgg': // Chiga
case 'dz': // Dzongkha
case 'fa': // Persian
case 'id': // Indonesian
case 'ja': // Japanese
case 'jbo': // Lojban
case 'ka': // Georgian
case 'kk': // Kazakh
case 'km': // Khmer
case 'ko': // Korean
case 'ky': // Kyrgyz
case 'lo': // Lao
case 'ms': // Malay
case 'my': // Burmese
case 'sah': // Yakut
case 'su': // Sundanese
case 'th': // Thai
case 'tt': // Tatar
case 'ug': // Uyghur
case 'vi': // Vietnamese
case 'wo': // Wolof
case 'zh':
// Chinese
// 1 form
return 0;
case 'is':
// Icelandic
// 2 forms
return n % 10 !== 1 || n % 100 === 11 ? 1 : 0;
case 'jv':
// Javanese
// 2 forms
return n !== 0 ? 1 : 0;
case 'mk':
// Macedonian
// 2 forms
return n === 1 || n % 10 === 1 ? 0 : 1;
case 'ach': // Acholi
case 'ak': // Akan
case 'am': // Amharic
case 'arn': // Mapudungun
case 'br': // Breton
case 'fil': // Filipino
case 'fr': // French
case 'gun': // Gun
case 'ln': // Lingala
case 'mfe': // Mauritian Creole
case 'mg': // Malagasy
case 'mi': // Maori
case 'oc': // Occitan
case 'pt_BR': // Brazilian Portuguese
case 'tg': // Tajik
case 'ti': // Tigrinya
case 'tr': // Turkish
case 'uz': // Uzbek
case 'wa': // Walloon
/* eslint-disable */
/* Disable "Duplicate case label" because there are 2 forms of Chinese plurals */
case 'zh':
// Chinese
/* eslint-enable */
// 2 forms
return n > 1 ? 1 : 0;
case 'lv':
// Latvian
// 3 forms
return n % 10 === 1 && n % 100 !== 11 ? 0 : n !== 0 ? 1 : 2;
case 'lt':
// Lithuanian
// 3 forms
return n % 10 === 1 && n % 100 !== 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'be': // Belarusian
case 'bs': // Bosnian
case 'hr': // Croatian
case 'ru': // Russian
case 'sr': // Serbian
case 'uk':
// Ukrainian
// 3 forms
return n % 10 === 1 && n % 100 !== 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'mnk':
// Mandinka
// 3 forms
return n === 0 ? 0 : n === 1 ? 1 : 2;
case 'ro':
// Romanian
// 3 forms
return n === 1 ? 0 : n === 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2;
case 'pl':
// Polish
// 3 forms
return n === 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'cs': // Czech
case 'sk':
// Slovak
// 3 forms
return n === 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2;
case 'csb':
// Kashubian
// 3 forms
return n === 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
case 'sl':
// Slovenian
// 4 forms
return n % 100 === 1 ? 0 : n % 100 === 2 ? 1 : n % 100 === 3 || n % 100 === 4 ? 2 : 3;
case 'mt':
// Maltese
// 4 forms
return n === 1 ? 0 : n === 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3;
case 'gd':
// Scottish Gaelic
// 4 forms
return n === 1 || n === 11 ? 0 : n === 2 || n === 12 ? 1 : n > 2 && n < 20 ? 2 : 3;
case 'cy':
// Welsh
// 4 forms
return n === 1 ? 0 : n === 2 ? 1 : n !== 8 && n !== 11 ? 2 : 3;
case 'kw':
// Cornish
// 4 forms
return n === 1 ? 0 : n === 2 ? 1 : n === 3 ? 2 : 3;
case 'ga':
// Irish
// 5 forms
return n === 1 ? 0 : n === 2 ? 1 : n > 2 && n < 7 ? 2 : n > 6 && n < 11 ? 3 : 4;
case 'ar':
// Arabic
// 6 forms
return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
default:
// Everything else
return n !== 1 ? 1 : 0;
}
}
};
/* vuex-i18n defines the Vuexi18nPlugin to enable localization using a vuex
** module to store the translation information. Make sure to also include the
** file vuex-i18n-store.js to include a respective vuex module.
*/
/* vuex-i18n defines the Vuexi18nPlugin to enable localization using a vuex
** module to store the translation information. Make sure to also include the
** file vuex-i18n-store.js to include a respective vuex module.
*/
// initialize the plugin object
var VuexI18nPlugin = {};
// initialize the plugin object
var VuexI18nPlugin = {};
// internationalization plugin for vue js using vuex
VuexI18nPlugin.install = function install(Vue, store, config) {
// internationalization plugin for vue js using vuex
VuexI18nPlugin.install = function install(Vue, store, config) {
// TODO: remove this block for next major update (API break)
if (typeof arguments[2] === 'string' || typeof arguments[3] === 'string') {
console.warn('i18n: Registering the plugin vuex-i18n with a string for `moduleName` or `identifiers` is deprecated. Use a configuration object instead.', 'https://github.com/dkfbasel/vuex-i18n#setup');
config = {
moduleName: arguments[2],
identifiers: arguments[3]
};
}
// TODO: remove this block for next major update (API break)
if (typeof arguments[2] === 'string' || typeof arguments[3] === 'string') {
console.warn('i18n: Registering the plugin vuex-i18n with a string for `moduleName` or `identifiers` is deprecated. Use a configuration object instead.', 'https://github.com/dkfbasel/vuex-i18n#setup');
config = {
moduleName: arguments[2],
identifiers: arguments[3]
};
}
// merge default options with user supplied options
var mergedConfig = Object.assign({
moduleName: 'i18n',
identifiers: ['{', '}'],
preserveState: false,
onTranslationNotFound: function onTranslationNotFound() {}
}, config);
// merge default options with user supplied options
config = Object.assign({
warnings: true,
moduleName: 'i18n',
identifiers: ['{', '}'],
preserveState: false,
translateFilterName: 'translate',
onTranslationNotFound: function onTranslationNotFound() {}
}, config);
// define module name and identifiers as constants to prevent any changes
var moduleName = mergedConfig.moduleName;
var identifiers = mergedConfig.identifiers;
// define module name and identifiers as constants to prevent any changes
var moduleName = config.moduleName;
var identifiers = config.identifiers;
var translateFilterName = config.translateFilterName;
// initialize the onTranslationNotFound function and make sure it is actually
// a function
var onTranslationNotFound = mergedConfig.onTranslationNotFound;
if (typeof onTranslationNotFound !== 'function') {
console.error('i18n: i18n config option onTranslationNotFound must be a function');
onTranslationNotFound = function onTranslationNotFound() {};
}
// initialize the onTranslationNotFound function and make sure it is actually
// a function
var onTranslationNotFound = config.onTranslationNotFound;
if (typeof onTranslationNotFound !== 'function') {
console.error('i18n: i18n config option onTranslationNotFound must be a function');
onTranslationNotFound = function onTranslationNotFound() {};
}
// register the i18n module in the vuex store
// preserveState can be used via configuration if server side rendering is used
store.registerModule(moduleName, i18nVuexModule, { preserveState: mergedConfig.preserveState });
// register the i18n module in the vuex store
// preserveState can be used via configuration if server side rendering is used
store.registerModule(moduleName, i18nVuexModule, { preserveState: config.preserveState });
// check if the plugin was correctly initialized
if (store.state.hasOwnProperty(moduleName) === false) {
console.error('i18n: i18n vuex module is not correctly initialized. Please check the module name:', moduleName);
// check if the plugin was correctly initialized
if (store.state.hasOwnProperty(moduleName) === false) {
console.error('i18n: i18n vuex module is not correctly initialized. Please check the module name:', moduleName);
// always return the key if module is not initialized correctly
Vue.prototype.$i18n = function (key) {
return key;
};
// always return the key if module is not initialized correctly
Vue.prototype.$i18n = function (key) {
return key;
};
Vue.prototype.$getLanguage = function () {
return null;
};
Vue.prototype.$getLanguage = function () {
return null;
};
Vue.prototype.$setLanguage = function () {
console.error('i18n: i18n vuex module is not correctly initialized');
};
Vue.prototype.$setLanguage = function () {
console.error('i18n: i18n vuex module is not correctly initialized');
};
return;
}
return;
}
// initialize the replacement function
var render = renderFn(identifiers, config.warnings);
// initialize the replacement function
var render = renderFn(identifiers);
// get localized string from store. note that we pass the arguments passed
// to the function directly to the translateInLanguage function
var translate = function $t() {
// get localized string from store. note that we pass the arguments passed
// to the function directly to the translateInLanguage function
var translate = function $t() {
// get the current language from the store
var locale = store.state[moduleName].locale;
// get the current language from the store
var locale = store.state[moduleName].locale;
return translateInLanguage.apply(undefined, [locale].concat(Array.prototype.slice.call(arguments)));
};
return translateInLanguage.apply(undefined, [locale].concat(Array.prototype.slice.call(arguments)));
};
// get localized string from store in a given language if available.
// there are two possible signatures for the function.
// we will check the arguments to make up the options passed.
// 1: locale, key, options, pluralization
// 2: locale, key, defaultValue, options, pluralization
var translateInLanguage = function translateInLanguage(locale) {
// get localized string from store in a given language if available.
// there are two possible signatures for the function.
// we will check the arguments to make up the options passed.
// 1: locale, key, options, pluralization
// 2: locale, key, defaultValue, options, pluralization
var translateInLanguage = function translateInLanguage(locale) {
// read the function arguments
var args = arguments;
// read the function arguments
var args = arguments;
// initialize options
var key = '';
var defaultValue = '';
var options = {};
var pluralization = null;
// initialize options
var key = '';
var defaultValue = '';
var options = {};
var pluralization = null;
var count = args.length;
var count = args.length;
// check if a default value was specified and fill options accordingly
if (count >= 3 && typeof args[2] === 'string') {
// check if a default value was specified and fill options accordingly
if (count >= 3 && typeof args[2] === 'string') {
key = args[1];
defaultValue = args[2];
key = args[1];
defaultValue = args[2];
if (count > 3) {
options = args[3];
}
if (count > 3) {
options = args[3];
}
if (count > 4) {
pluralization = args[4];
}
} else {
if (count > 4) {
pluralization = args[4];
}
} else {
key = args[1];
key = args[1];
// default value was not specified and is therefore the same as the key
defaultValue = key;
// default value was not specified and is therefore the same as the key
defaultValue = key;
if (count > 2) {
options = args[2];
}
if (count > 2) {
options = args[2];
}
if (count > 3) {
pluralization = args[3];
}
}
if (count > 3) {
pluralization = args[3];
}
}
// return the default value if the locale is not set (could happen on initialization)
if (!locale) {
if (config.warnings) console.warn('i18n: i18n locale is not set when trying to access translations:', key);
return defaultValue;
}
// return the default value if the locale is not set (could happen on initialization)
if (!locale) {
console.warn('i18n: i18n locale is not set when trying to access translations:', key);
return defaultValue;
}
// get the translations from the store
var translations = store.state[moduleName].translations;
// get the translations from the store
var translations = store.state[moduleName].translations;
// get the last resort fallback from the store
var fallback = store.state[moduleName].fallback;
// get the last resort fallback from the store
var fallback = store.state[moduleName].fallback;
// split locale by - to support partial fallback for regional locales
// like de-CH, en-UK
var localeRegional = locale.split('-');
// split locale by - to support partial fallback for regional locales
// like de-CH, en-UK
var localeRegional = locale.split('-');
// flag for translation to exist or not
var translationExists = true;
// flag for translation to exist or not
var translationExists = true;
// check if the language exists in the store. return the key if not
if (translations.hasOwnProperty(locale) === false) {
translationExists = false;
// check if the language exists in the store. return the key if not
if (translations.hasOwnProperty(locale) === false) {
translationExists = false;
// check if the key exists in the store. return the key if not
} else if (translations[locale].hasOwnProperty(key) === false) {
translationExists = false;
}
// check if the key exists in the store. return the key if not
} else if (translations[locale].hasOwnProperty(key) === false) {
translationExists = false;
}
// return the value from the store
if (translationExists === true) {
return render(locale, translations[locale][key], options, pluralization);
}
// return the value from the store
if (translationExists === true) {
return render(locale, translations[locale][key], options, pluralization);
}
// check if a regional locale translation would be available for the key
// i.e. de for de-CH
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) === true && translations[localeRegional[0]].hasOwnProperty(key) === true) {
return render(localeRegional[0], translations[localeRegional[0]][key], options, pluralization);
}
// check if a regional locale translation would be available for the key
// i.e. de for de-CH
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) === true && translations[localeRegional[0]].hasOwnProperty(key) === true) {
return render(localeRegional[0], translations[localeRegional[0]][key], options, pluralization);
}
// invoke a method if a translation is not found
var asyncTranslation = onTranslationNotFound(locale, key, defaultValue);
// invoke a method if a translation is not found
var asyncTranslation = onTranslationNotFound(locale, key, defaultValue);
// resolve async translations by updating the store
if (asyncTranslation) {
Promise.resolve(asyncTranslation).then(function (value) {
var additionalTranslations = {};
additionalTranslations[key] = value;
addLocale(locale, additionalTranslations);
});
}
// resolve async translations by updating the store
if (asyncTranslation) {
Promise.resolve(asyncTranslation).then(function (value) {
var additionalTranslations = {};
additionalTranslations[key] = value;
addLocale(locale, additionalTranslations);
});
}
// check if a vaild fallback exists in the store.
// return the default value if not
if (translations.hasOwnProperty(fallback) === false) {
return render(locale, defaultValue, options, pluralization);
}
// check if a vaild fallback exists in the store.
// return the default value if not
if (translations.hasOwnProperty(fallback) === false) {
return render(locale, defaultValue, options, pluralization);
}
// check if the key exists in the fallback locale in the store.
// return the default value if not
if (translations[fallback].hasOwnProperty(key) === false) {
return render(fallback, defaultValue, options, pluralization);
}
// check if the key exists in the fallback locale in the store.
// return the default value if not
if (translations[fallback].hasOwnProperty(key) === false) {
return render(fallback, defaultValue, options, pluralization);
}
return render(locale, translations[fallback][key], options, pluralization);
};
return render(locale, translations[fallback][key], options, pluralization);
};
// check if the given key exists in the current locale
var checkKeyExists = function checkKeyExists(key) {
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fallback';
// check if the given key exists in the current locale
var checkKeyExists = function checkKeyExists(key) {
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fallback';
// get the current language from the store
var locale = store.state[moduleName].locale;
var fallback = store.state[moduleName].fallback;
var translations = store.state[moduleName].translations;
// get the current language from the store
var locale = store.state[moduleName].locale;
var fallback = store.state[moduleName].fallback;
var translations = store.state[moduleName].translations;
// check the current translation
if (translations.hasOwnProperty(locale) && translations[locale].hasOwnProperty(key)) {
return true;
}
// check the current translation
if (translations.hasOwnProperty(locale) && translations[locale].hasOwnProperty(key)) {
return true;
}
if (scope == 'strict') {
return false;
}
if (scope == 'strict') {
return false;
}
// check any localized translations
var localeRegional = locale.split('-');
// check any localized translations
var localeRegional = locale.split('-');
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) && translations[localeRegional[0]].hasOwnProperty(key)) {
return true;
}
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) && translations[localeRegional[0]].hasOwnProperty(key)) {
return true;
}
if (scope == 'locale') {
return false;
}
if (scope == 'locale') {
return false;
}
// check if a fallback locale exists
if (translations.hasOwnProperty(fallback) && translations[fallback].hasOwnProperty(key)) {
return true;
}
// check if a fallback locale exists
if (translations.hasOwnProperty(fallback) && translations[fallback].hasOwnProperty(key)) {
return true;
}
// key does not exist in the store
return false;
};
// key does not exist in the store
return false;
};
// set fallback locale
var setFallbackLocale = function setFallbackLocale(locale) {
store.dispatch({
type: moduleName + '/setFallbackLocale',
locale: locale
});
};
// set fallback locale
var setFallbackLocale = function setFallbackLocale(locale) {
store.dispatch({
type: moduleName + '/setFallbackLocale',
locale: locale
});
};
// set the current locale
var setLocale = function setLocale(locale) {
store.dispatch({
type: moduleName + '/setLocale',
locale: locale
});
};
// set the current locale
var setLocale = function setLocale(locale) {
store.dispatch({
type: moduleName + '/setLocale',
locale: locale
});
};
// get the current locale
var getLocale = function getLocale() {
return store.state[moduleName].locale;
};
// get the current locale
var getLocale = function getLocale() {
return store.state[moduleName].locale;
};
// get all available locales
var getLocales = function getLocales() {
return Object.keys(store.state[moduleName].translations);
};
// get all available locales
var getLocales = function getLocales() {
return Object.keys(store.state[moduleName].translations);
};
// add predefined translations to the store (keeping existing information)
var addLocale = function addLocale(locale, translations) {
return store.dispatch({
type: moduleName + '/addLocale',
locale: locale,
translations: translations
});
};
// add predefined translations to the store (keeping existing information)
var addLocale = function addLocale(locale, translations) {
return store.dispatch({
type: moduleName + '/addLocale',
locale: locale,
translations: translations
});
};
// replace all locale information in the store
var replaceLocale = function replaceLocale(locale, translations) {
return store.dispatch({
type: moduleName + '/replaceLocale',
locale: locale,
translations: translations
});
};
// replace all locale information in the store
var replaceLocale = function replaceLocale(locale, translations) {
return store.dispatch({
type: moduleName + '/replaceLocale',
locale: locale,
translations: translations
});
};
// remove the givne locale from the store
var removeLocale = function removeLocale(locale) {
if (store.state[moduleName].translations.hasOwnProperty(locale)) {
store.dispatch({
type: moduleName + '/removeLocale',
locale: locale
});
}
};
// remove the givne locale from the store
var removeLocale = function removeLocale(locale) {
if (store.state[moduleName].translations.hasOwnProperty(locale)) {
store.dispatch({
type: moduleName + '/removeLocale',
locale: locale
});
}
};
// we are phasing out the exists function
var phaseOutExistsFn = function phaseOutExistsFn(locale) {
if (config.warnings) console.warn('i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exactly the same functionality.');
return checkLocaleExists(locale);
};
// we are phasing out the exists function
var phaseOutExistsFn = function phaseOutExistsFn(locale) {
console.warn('i18n: $i18n.exists is depreceated. Please use $i18n.localeExists instead. It provides exatly the same functionality.');
return checkLocaleExists(locale);
};
// check if the given locale is already loaded
var checkLocaleExists = function checkLocaleExists(locale) {
return store.state[moduleName].translations.hasOwnProperty(locale);
};
// check if the given locale is already loaded
var checkLocaleExists = function checkLocaleExists(locale) {
return store.state[moduleName].translations.hasOwnProperty(locale);
};
// register vue prototype methods
Vue.prototype.$i18n = {
locale: getLocale,
locales: getLocales,
set: setLocale,
add: addLocale,
replace: replaceLocale,
remove: removeLocale,
fallback: setFallbackLocale,
localeExists: checkLocaleExists,
keyExists: checkKeyExists,
// register vue prototype methods
Vue.prototype.$i18n = {
locale: getLocale,
locales: getLocales,
set: setLocale,
add: addLocale,
replace: replaceLocale,
remove: removeLocale,
fallback: setFallbackLocale,
localeExists: checkLocaleExists,
keyExists: checkKeyExists,
translate: translate,
translateIn: translateInLanguage,
translate: translate,
translateIn: translateInLanguage,
exists: phaseOutExistsFn
};
exists: phaseOutExistsFn
};
// register global methods
Vue.i18n = {
locale: getLocale,
locales: getLocales,
set: setLocale,
add: addLocale,
replace: replaceLocale,
remove: removeLocale,
fallback: setFallbackLocale,
translate: translate,
translateIn: translateInLanguage,
localeExists: checkLocaleExists,
keyExists: checkKeyExists,
// register global methods
Vue.i18n = {
locale: getLocale,
locales: getLocales,
set: setLocale,
add: addLocale,
replace: replaceLocale,
remove: removeLocale,
fallback: setFallbackLocale,
translate: translate,
translateIn: translateInLanguage,
localeExists: checkLocaleExists,
keyExists: checkKeyExists,
exists: phaseOutExistsFn
};
exists: phaseOutExistsFn
};
// register the translation function on the vue instance directly
Vue.prototype.$t = translate;
// register the translation function on the vue instance directly
Vue.prototype.$t = translate;
// register the specific language translation function on the vue instance directly
Vue.prototype.$tlang = translateInLanguage;
// register the specific language translation function on the vue instance directly
Vue.prototype.$tlang = translateInLanguage;
// register a filter function for translations
Vue.filter(translateFilterName, translate);
};
// register a filter function for translations
Vue.filter('translate', translate);
};
// renderFn will initialize a function to render the variable substitutions in
// the translation string. identifiers specify the tags will be used to find
// variable substitutions, i.e. {test} or {{test}}, note that we are using a
// closure to avoid recompilation of the regular expression to match tags on
// every render cycle.
var renderFn = function renderFn(identifiers) {
var warnings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
// renderFn will initialize a function to render the variable substitutions in
// the translation string. identifiers specify the tags will be used to find
// variable substitutions, i.e. {test} or {{test}}, note that we are using a
// closure to avoid recompilation of the regular expression to match tags on
// every render cycle.
var renderFn = function renderFn(identifiers) {
if (identifiers == null || identifiers.length != 2) {
console.warn('i18n: You must specify the start and end character identifying variable substitutions');
}
if (identifiers == null || identifiers.length != 2) {
console.warn('i18n: You must specify the start and end character identifying variable substitutions');
}
// construct a regular expression ot find variable substitutions, i.e. {test}
var matcher = new RegExp('' + identifiers[0] + '\\w+' + identifiers[1], 'g');
// construct a regular expression ot find variable substitutions, i.e. {test}
var matcher = new RegExp('' + identifiers[0] + '{1}\\w.+?' + identifiers[1] + '{1}', 'g');
// define the replacement function
var replace = function replace(translation, replacements) {
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// define the replacement function
var replace = function replace(translation, replacements) {
// check if the object has a replace property
if (!translation.replace) {
return translation;
}
// check if the object has a replace property
if (!translation.replace) {
return translation;
}
return translation.replace(matcher, function (placeholder) {
return translation.replace(matcher, function (placeholder) {
// remove the identifiers (can be set on the module level)
var key = placeholder.replace(identifiers[0], '').replace(identifiers[1], '');
// remove the identifiers (can be set on the module level)
var key = placeholder.replace(identifiers[0], '').replace(identifiers[1], '');
if (replacements[key] !== undefined) {
return replacements[key];
}
if (replacements[key] !== undefined) {
return replacements[key];
}
// warn user that the placeholder has not been found
if (warnings) {
console.group ? console.group('i18n: Not all placeholders found') : console.warn('i18n: Not all placeholders found');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
if (console.groupEnd) {
console.groupEnd();
}
}
// warn user that the placeholder has not been found
if (warn === true) {
console.group ? console.group('i18n: Not all placeholders found') : console.warn('i18n: Not all placeholders found');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
if (console.groupEnd) {
console.groupEnd();
}
}
// return the original placeholder
return placeholder;
});
};
// return the original placeholder
return placeholder;
});
};
// the render function will replace variable substitutions and prepare the
// translations for rendering
var render = function render(locale, translation) {
var replacements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var pluralization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
// the render function will replace variable substitutions and prepare the
// translations for rendering
var render = function render(locale, translation) {
var replacements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var pluralization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
// get the type of the property
var objType = typeof translation === 'undefined' ? 'undefined' : _typeof(translation);
var pluralizationType = typeof pluralization === 'undefined' ? 'undefined' : _typeof(pluralization);
// get the type of the property
var objType = typeof translation === 'undefined' ? 'undefined' : _typeof(translation);
var pluralizationType = typeof pluralization === 'undefined' ? 'undefined' : _typeof(pluralization);
var resolvePlaceholders = function resolvePlaceholders() {
var resolvePlaceholders = function resolvePlaceholders() {
if (isArray$1(translation)) {
if (isArray$1(translation)) {
// replace the placeholder elements in all sub-items
return translation.map(function (item) {
return replace(item, replacements, false);
});
} else if (objType === 'string') {
return replace(translation, replacements, true);
}
};
// replace the placeholder elements in all sub-items
return translation.map(function (item) {
return replace(item, replacements, false);
});
} else if (objType === 'string') {
return replace(translation, replacements, true);
}
};
// return translation item directly
if (pluralization === null) {
return resolvePlaceholders();
}
// return translation item directly
if (pluralization === null) {
return resolvePlaceholders();
}
// check if pluralization value is countable
if (pluralizationType !== 'number') {
if (warnings) console.warn('i18n: pluralization is not a number');
return resolvePlaceholders();
}
// check if pluralization value is countable
if (pluralizationType !== 'number') {
console.warn('i18n: pluralization is not a number');
return resolvePlaceholders();
}
// --- handle pluralizations ---
// --- handle pluralizations ---
// replace all placeholders
var resolvedTranslation = resolvePlaceholders();
// replace all placeholders
var resolvedTranslation = resolvePlaceholders();
// initialize pluralizations
var pluralizations = null;
// initialize pluralizations
var pluralizations = null;
// if translations are already an array and have more than one entry,
// we will not perform a split operation on :::
if (isArray$1(resolvedTranslation) && resolvedTranslation.length > 0) {
pluralizations = resolvedTranslation;
} else {
// split translation strings by ::: to find create the pluralization array
pluralizations = resolvedTranslation.split(':::');
}
// if translations are already an array and have more than one entry,
// we will not perform a split operation on :::
if (isArray$1(resolvedTranslation) && resolvedTranslation.length > 0) {
pluralizations = resolvedTranslation;
} else {
// split translation strings by ::: to find create the pluralization array
pluralizations = resolvedTranslation.split(':::');
}
// determine the pluralization version to use by locale
var index = plurals.getTranslationIndex(locale, pluralization);
// determine the pluralization version to use by locale
var index = plurals.getTranslationIndex(locale, pluralization);
// check if the specified index is present in the pluralization
if (typeof pluralizations[index] === 'undefined') {
if (warnings) {
console.warn('i18n: pluralization not provided in locale', translation, locale, index);
}
// check if the specified index is present in the pluralization
if (typeof pluralizations[index] === 'undefined') {
console.warn('i18n: pluralization not provided in locale', translation, locale, index);
// return the first element of the pluralization by default
return pluralizations[0].trim();
}
// return the first element of the pluralization by default
return pluralizations[0].trim();
}
// return the requested item from the pluralizations
return pluralizations[index].trim();
};
// return the requested item from the pluralizations
return pluralizations[index].trim();
};
// return the render function to the caller
return render;
};
// return the render function to the caller
return render;
};
// check if the given object is an array
function isArray$1(obj) {
return !!obj && Array === obj.constructor;
}
// check if the given object is an array
function isArray$1(obj) {
return !!obj && Array === obj.constructor;
}
// export both modules as one file
var index = {
store: i18nVuexModule,
plugin: VuexI18nPlugin
};
// import the vuex module for localization
// import the corresponding plugin for vue
// export both modules as one file
var index = {
store: i18nVuexModule,
plugin: VuexI18nPlugin
};
return index;
return index;
})));
{
"name": "vuex-i18n",
"version": "1.10.5",
"version": "1.10.7",
"description": "Easy localization for vue-components using vuex as data store",
"directories": {
"test": "test"
"test": "test",
"doc": "docs",
"lib": "src"
},

@@ -15,3 +17,3 @@ "main": "dist/vuex-i18n.es.js",

"build": "rollup -c rollup.config.js",
"minify": "uglifyjs dist/vuex-i18n.umd.js --output dist/vuex-i18n.min.js --compress"
"minify": "uglifyjs dist/vuex-i18n.umd.js --output dist/vuex-i18n.min.js --compress --mangle"
},

@@ -50,11 +52,3 @@ "repository": {

},
"homepage": "https://github.com/dkfbasel/vuex-i18n#readme",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-plugin-external-helpers": "^6.18.0",
"babel-preset-env": "^1.6.1",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.6",
"uglify-es": "^3.1.6"
}
"homepage": "https://github.com/dkfbasel/vuex-i18n#readme"
}

@@ -58,3 +58,3 @@ # vuex-i18n

// please note that you must specify the name of the vuex module if it is
// different from i18n. i.e. Vue.use(vuexI18n.plugin, store, 'myName')
// different from i18n. i.e. Vue.use(vuexI18n.plugin, store, {moduleName: 'myName'})

@@ -160,3 +160,26 @@

```
## Config
You can pass a config object as the third parameter when use vuex-i18n.
i.e. Vue.use(vuexI18n.plugin, store, config)
At present, the configuration options that are supported are as follows:
- `moduleName` (default `i18n`)
- `identifiers` (default `['{', '}']`)
- `preserveState` (default `false`)
- `translateFilterName` (default `translate`)
- `onTranslationNotFound` (default `function(){}`)
- `warnings`: default(`true`)
```javascript
const config = {
moduleName: 'myName',
translateFilterName: 't'
}
Vue.use(vuexI18n.plugin, store, config)
```
## Usage

@@ -290,2 +313,5 @@ vuex-i18n provides easy access to localized information through the use of

// get all available locales
// is is however recommended to use a computed property to fetch the locales
// returning Object.keys(this.$store.state.i18n.translations); as this will
// make use of vue's caching system.
$i18n.locales(), Vue.i18n.locales()

@@ -292,0 +318,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc