Socket
Socket
Sign inDemoInstall

vue3-i18n

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-i18n - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

dist/index.esm.js

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

import{ref as e,inject as t}from"vue";const n=Symbol("i18n"),o=(e,t,n)=>{const r=e[0];if(~r.indexOf("[")){const[l,a]=r.split("["),s=parseInt(a.replace("]",""));if(s>-1){if(!t[l]&&t[l].length>0&&t[l][s]&&""!==t[l][s])throw new Error("Not Found");return 1===e.length?"string"==typeof t[l][s]?t[l][s]:"":o(e.slice(1),t[l][s],n)}throw new Error(`Not Found: ${r}`)}if(t[e[0]]||""===t[e[0]]){if(1===e.length){let o="string"==typeof t[e[0]]?t[e[0]]:"";return n&&(o=((e,t)=>{const n=/{(\w*)}/g;let o,r=e;for(;null!==(o=n.exec(e));){if(console.log(o),!Object.prototype.hasOwnProperty.call(t,o[1]))throw new Error(`Not Found Params: ${o[1]}`);r=r.replace(o[0],t[o[1]])}return r})(o,n)),o}return o(e.slice(1),t[e[0]],n)}throw new Error("Not Found")},r=t=>{const r=e(t.locale||"en"),l=t.messages;return{messages:l,t:(e,t)=>{const n=l[r.value]||l.en;if("string"!=typeof e)return console.warn("Warn(i18n):","keypath must be a type of string"),"";try{return o(e.split("."),n,t)}catch(t){return console.log(t),console.warn(`Warn(i18n): the keypath '${e}' not found`),""}},setLocale:e=>{l[e]||console.warn(`Warn(i18n): the '${e}' language pack not found, fall back to English language pack`),r.value=e},getLocale:()=>r.value,install(e){const t=this;e.provide(n,t),e.config.globalProperties.$t=t.t,e.config.globalProperties.$i18n=t}}};function l(){return t(n)}export{r as createI18n,n as i18nSymbol,l as useI18n};
import{ref as e,inject as t}from"vue";const n=Symbol("i18n"),r=(e,t,n)=>{const o=e[0];if(~o.indexOf("[")){const[l,a]=o.split("["),s=parseInt(a.replace("]",""));if(s>-1){if(!t[l]&&t[l].length>0&&t[l][s]&&""!==t[l][s])throw new Error("Not Found");return 1===e.length?"string"==typeof t[l][s]?t[l][s]:"":r(e.slice(1),t[l][s],n)}throw new Error(`Not Found: ${o}`)}if(t[e[0]]||""===t[e[0]]){if(1===e.length){let r="string"==typeof t[e[0]]?t[e[0]]:"";return n&&(r=((e,t)=>{const n=/{(\w*)}/g;let r,o=e;for(;null!==(r=n.exec(e));){if(!Object.prototype.hasOwnProperty.call(t,r[1]))throw new Error(`Not Found Params: ${r[1]}`);o=o.replace(r[0],t[r[1]])}return o})(r,n)),r}return r(e.slice(1),t[e[0]],n)}throw new Error("Not Found")},o=t=>{const o=e(t.locale||"en"),l=t.messages;return{messages:l,t:(e,t)=>{const n=l[o.value]||l.en;if("string"!=typeof e)return console.warn("Warn(i18n):","keypath must be a type of string"),"";try{return r(e.split("."),n,t)}catch(t){return console.warn(`Warn(i18n): the keypath '${e}' not found`),""}},setLocale:e=>{l[e]||console.warn(`Warn(i18n): the '${e}' language pack not found, fall back to English language pack`),o.value=e},getLocale:()=>o.value,install(e){const t=this;e.provide(n,t),e.config.globalProperties.$t=t.t,e.config.globalProperties.$i18n=t}}};function l(){return t(n)}export{o as createI18n,n as i18nSymbol,l as useI18n};
{
"name": "vue3-i18n",
"version": "1.1.0",
"version": "1.1.1",
"description": "A i18n plugin for Vue3",

@@ -5,0 +5,0 @@ "main": "dist/index.esm.js",

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