@lytjs/plugin-i18n 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +41 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var x=(r,i)=>{for(var o in i)u(r,o,{get:i[o],enumerable:!0})},C=(r,i,o,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of P(i))!j.call(r,t)&&t!==o&&u(r,t,{get:()=>i[t],enumerable:!(e=M(i,t))||e.enumerable});return r};var A=r=>C(u({},"__esModule",{value:!0}),r);var z={};x(z,{createI18n:()=>$});module.exports=A(z);function m(r,i){let o=i.split("."),e=r;for(let t of o){if(e==null||typeof e!="object")return;e=e[t]}return typeof e=="string"?e:void 0}function y(r,i){return r.replace(/\{(\w+)\}/g,(o,e)=>i[e]!==void 0?String(i[e]):o)}function F(r,i,o){if(!r.includes("|"))return y(r,o);let e=r.split("|").map(g=>g.trim()),t;return i===0&&e.length>0?t=(e.length>=3,e[0]):i===1?t=e.length>=2?e[1]:e[0]:t=e.length>=3?e[2]:e.length>=2?e[1]:e[0],y(t,{...o,count:i})}function $(r){let{locale:i,fallbackLocale:o,messages:e}=r,t={};for(let n of Object.keys(e))t[n]={...e[n]};let g=i,f=[];function L(n){return f.push(n),()=>{let s=f.indexOf(n);s>-1&&f.splice(s,1)}}function R(n){for(let s of f)s(n)}function v(n,s,c){let a=s||{},l=m(t[g]||{},n);if(l===void 0&&o&&(l=m(t[o]||{},n)),l===void 0)if(c!==void 0)l=c;else return n;return a.count!==void 0&&typeof a.count=="number"?F(l,a.count,a):y(l,a)}function p(n){n!==g&&(g=n,R(n))}function h(){return g}function I(){return Object.keys(t)}function b(n,s){t[n]||(t[n]={});for(let c of Object.keys(s))t[n][c]=s[c]}function O(n,s){b(n,s)}function k(n,s){t[n]={...s}}let d={install(n,s){n.config=n.config||{},n.config.globalProperties=n.config.globalProperties||{},n.config.globalProperties.$t=v,n.config.globalProperties.$i18n=d.global,typeof n.provide=="function"&&n.provide("i18n",d.global)},global:{t:v,get locale(){return g},setLocale:p,getLocale:h,get availableLocales(){return I()},mergeMessage:b,mergeLocaleMessages:O,loadLocaleMessages:k,onLocaleChange:L}};return d}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function b(o,r){let s=r.split("."),e=o;for(let t of s){if(e==null||typeof e!="object")return;e=e[t]}return typeof e=="string"?e:void 0}function u(o,r){return o.replace(/\{(\w+)\}/g,(s,e)=>r[e]!==void 0?String(r[e]):s)}function k(o,r,s){if(!o.includes("|"))return u(o,s);let e=o.split("|").map(g=>g.trim()),t;return r===0&&e.length>0?t=(e.length>=3,e[0]):r===1?t=e.length>=2?e[1]:e[0]:t=e.length>=3?e[2]:e.length>=2?e[1]:e[0],u(t,{...s,count:r})}function M(o){let{locale:r,fallbackLocale:s,messages:e}=o,t={};for(let n of Object.keys(e))t[n]={...e[n]};let g=r,f=[];function m(n){return f.push(n),()=>{let i=f.indexOf(n);i>-1&&f.splice(i,1)}}function L(n){for(let i of f)i(n)}function y(n,i,c){let a=i||{},l=b(t[g]||{},n);if(l===void 0&&s&&(l=b(t[s]||{},n)),l===void 0)if(c!==void 0)l=c;else return n;return a.count!==void 0&&typeof a.count=="number"?k(l,a.count,a):u(l,a)}function R(n){n!==g&&(g=n,L(n))}function p(){return g}function h(){return Object.keys(t)}function v(n,i){t[n]||(t[n]={});for(let c of Object.keys(i))t[n][c]=i[c]}function I(n,i){v(n,i)}function O(n,i){t[n]={...i}}let d={install(n,i){n.config=n.config||{},n.config.globalProperties=n.config.globalProperties||{},n.config.globalProperties.$t=y,n.config.globalProperties.$i18n=d.global,typeof n.provide=="function"&&n.provide("i18n",d.global)},global:{t:y,get locale(){return g},setLocale:R,getLocale:p,get availableLocales(){return h()},mergeMessage:v,mergeLocaleMessages:I,loadLocaleMessages:O,onLocaleChange:m}};return d}export{M as createI18n};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lytjs/plugin-i18n",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Lyt.js 国际化插件 - 提供多语言支持、消息格式化和语言切换功能",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"module": "./src/index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./src/index.ts",
|
|
10
|
+
"require": "./src/index.ts",
|
|
11
|
+
"default": "./src/index.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": ["dist"],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "lytjs",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://gitee.com/@lytjs/lytjs"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://gitee.com/@lytjs/lytjs",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"lyt",
|
|
25
|
+
"lytjs",
|
|
26
|
+
"javascript",
|
|
27
|
+
"framework",
|
|
28
|
+
"frontend",
|
|
29
|
+
"vue-like",
|
|
30
|
+
"lightweight",
|
|
31
|
+
"zero-dependency",
|
|
32
|
+
"i18n",
|
|
33
|
+
"internationalization",
|
|
34
|
+
"locale",
|
|
35
|
+
"translation",
|
|
36
|
+
"国际化"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|