@kong-ui-public/i18n 0.6.2-pr.616.e3701a8.0 → 0.7.1-pr.618.1de3214.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/README.md +36 -1
- package/dist/i18n.es.js +12 -12
- package/dist/i18n.umd.js +1 -1
- package/dist/types/Translation.d.ts +1 -1
- package/dist/types/Translation.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
- [HTML safe formatting with `<i18n-t>`](#html-safe-formatting-with-i18n-t)
|
|
13
13
|
- [Formatting numbers, dates and times](#formatting-numbers-dates-and-times)
|
|
14
14
|
- [Additional service functions.](#additional-service-functions)
|
|
15
|
+
- [formatUnixTimeStamp](#formatunixtimestamp)
|
|
16
|
+
- [formatIsoDate](#formatisodate)
|
|
15
17
|
- [te](#te)
|
|
16
18
|
- [tm](#tm)
|
|
17
19
|
|
|
@@ -395,6 +397,40 @@ Every single method listed in [FormatJS](https://formatjs.io/docs/intl) is expos
|
|
|
395
397
|
|
|
396
398
|
(as previously exposed by vue18n-n)
|
|
397
399
|
|
|
400
|
+
### formatUnixTimeStamp
|
|
401
|
+
|
|
402
|
+
Formats a unix timestamp into a formatted date string
|
|
403
|
+
|
|
404
|
+
`code:`
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
const { formatUnixTimeStamp } = useI18n()
|
|
408
|
+
console.log(formatUnixTimeStamp('1558006979'))
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
`result:`
|
|
412
|
+
|
|
413
|
+
```json
|
|
414
|
+
May 16, 2019, 11:42 AM
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### formatIsoDate
|
|
418
|
+
|
|
419
|
+
Format an ISO formatted date
|
|
420
|
+
|
|
421
|
+
`code:`
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
const { formatIsoDate } = useI18n()
|
|
425
|
+
console.log(formatIsoDate('2019-05-16T11:42:59.000Z'))
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
`result:`
|
|
429
|
+
|
|
430
|
+
```json
|
|
431
|
+
May 16, 2019, 11:42 AM
|
|
432
|
+
```
|
|
433
|
+
|
|
398
434
|
### te
|
|
399
435
|
|
|
400
436
|
check if translation message exists
|
|
@@ -412,7 +448,6 @@ check if translation message exists
|
|
|
412
448
|
```ts
|
|
413
449
|
const { te } = useI18n()
|
|
414
450
|
console.log({p: te('global.ok'), n: te('global.not.ok')})
|
|
415
|
-
console.log()
|
|
416
451
|
```
|
|
417
452
|
|
|
418
453
|
`result:`
|
package/dist/i18n.es.js
CHANGED
|
@@ -3294,13 +3294,13 @@ const pr = (e, t, n = !1) => {
|
|
|
3294
3294
|
})
|
|
3295
3295
|
},
|
|
3296
3296
|
fr
|
|
3297
|
-
), i = (p) => {
|
|
3297
|
+
), { $t: i, ...a } = r, o = a, s = (p) => {
|
|
3298
3298
|
const v = "Invalid Date";
|
|
3299
3299
|
if (!p)
|
|
3300
3300
|
return v;
|
|
3301
3301
|
try {
|
|
3302
3302
|
const E = new Date(p * 1e3);
|
|
3303
|
-
return
|
|
3303
|
+
return o.formatDate(E, {
|
|
3304
3304
|
year: "numeric",
|
|
3305
3305
|
month: "short",
|
|
3306
3306
|
day: "numeric",
|
|
@@ -3310,16 +3310,16 @@ const pr = (e, t, n = !1) => {
|
|
|
3310
3310
|
} catch {
|
|
3311
3311
|
return v;
|
|
3312
3312
|
}
|
|
3313
|
-
},
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
t: (p, v, E) =>
|
|
3320
|
-
te: (p) => !!
|
|
3321
|
-
tm: (p) =>
|
|
3322
|
-
...
|
|
3313
|
+
}, c = {
|
|
3314
|
+
formatUnixTimeStamp: s,
|
|
3315
|
+
formatIsoDate: (p) => {
|
|
3316
|
+
const v = Date.parse(p) / 1e3;
|
|
3317
|
+
return s(v);
|
|
3318
|
+
},
|
|
3319
|
+
t: (p, v, E) => o.formatMessage({ id: p }, v, E),
|
|
3320
|
+
te: (p) => !!o.messages[p],
|
|
3321
|
+
tm: (p) => o.messages[p] || [],
|
|
3322
|
+
...o,
|
|
3323
3323
|
source: t
|
|
3324
3324
|
};
|
|
3325
3325
|
return (typeof n == "boolean" && n === !0 || typeof n != "boolean" && n.isGlobal === !0) && (Ve = c), c;
|
package/dist/i18n.umd.js
CHANGED
|
@@ -19,4 +19,4 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
|
19
19
|
Try polyfilling it using "@formatjs/intl-relativetimeformat"
|
|
20
20
|
`,P.MISSING_INTL_API));try{return nr(e,t,i).format(n,r)}catch(o){e.onError(new I("Error formatting relative time.",e.locale,o))}return String(n)}var ar=["style","currency","currencyDisplay","unit","unitDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","currencyDisplay","currencySign","notation","signDisplay","unit","unitDisplay","numberingSystem"];function Ge(e,t,n){var r=e.locale,i=e.formats,a=e.onError;n===void 0&&(n={});var o=n.format,s=o&&ae(i,"number",o,a)||{},h=M(n,ar,s);return t(r,h)}function or(e,t,n,r){r===void 0&&(r={});try{return Ge(e,t,r).format(n)}catch(i){e.onError(new I("Error formatting number.",e.locale,i))}return String(n)}function sr(e,t,n,r){r===void 0&&(r={});try{return Ge(e,t,r).formatToParts(n)}catch(i){e.onError(new I("Error formatting number.",e.locale,i))}return[]}function ur(e){var t=e?e[Object.keys(e)[0]]:void 0;return typeof t=="string"}function hr(e){e.onWarn&&e.defaultRichTextElements&&ur(e.messages||{})&&e.onWarn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
|
|
21
21
|
Please consider using "@formatjs/cli" to pre-compile your messages for performance.
|
|
22
|
-
For more details see https://formatjs.io/docs/getting-started/message-distribution`)}function lr(e,t){var n=Vt(t),r=m(m({},jt),e),i=r.locale,a=r.defaultLocale,o=r.onError;return i?!Intl.NumberFormat.supportedLocalesOf(i).length&&o?o(new Oe('Missing locale data for locale: "'.concat(i,'" in Intl.NumberFormat. Using default locale: "').concat(a,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):!Intl.DateTimeFormat.supportedLocalesOf(i).length&&o&&o(new Oe('Missing locale data for locale: "'.concat(i,'" in Intl.DateTimeFormat. Using default locale: "').concat(a,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):(o&&o(new wt('"locale" was not configured, using "'.concat(a,'" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details'))),r.locale=r.defaultLocale||"en"),hr(r),m(m({},r),{formatters:n,formatNumber:or.bind(null,r,n.getNumberFormat),formatNumberToParts:sr.bind(null,r,n.getNumberFormat),formatRelativeTime:ir.bind(null,r,n.getRelativeTimeFormat),formatDate:Xt.bind(null,r,n.getDateTimeFormat),formatDateToParts:zt.bind(null,r,n.getDateTimeFormat),formatTime:Zt.bind(null,r,n.getDateTimeFormat),formatDateTimeRange:Wt.bind(null,r,n.getDateTimeFormat),formatTimeToParts:qt.bind(null,r,n.getDateTimeFormat),formatPlural:tr.bind(null,r,n.getPluralRules),formatMessage:Ce.bind(null,r,n),$t:Ce.bind(null,r,n),formatList:Kt.bind(null,r,n.getListFormat),formatListToParts:Fe.bind(null,r,n.getListFormat),formatDisplayName:Qt.bind(null,r,n.getDisplayNames)})}var fr=U;U.flatten=U,U.unflatten=Ve;function Ue(e){return e&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function je(e){return e}function U(e,t){t=t||{};const n=t.delimiter||".",r=t.maxDepth,i=t.transformKey||je,a={};function o(s,h,l){l=l||1,Object.keys(s).forEach(function(u){const f=s[u],c=t.safe&&Array.isArray(f),p=Object.prototype.toString.call(f),b=Ue(f),E=p==="[object Object]"||p==="[object Array]",y=h?h+n+i(u):i(u);if(!c&&!b&&E&&Object.keys(f).length&&(!t.maxDepth||l<r))return o(f,y,l+1);a[y]=f})}return o(e),a}function Ve(e,t){t=t||{};const n=t.delimiter||".",r=t.overwrite||!1,i=t.transformKey||je,a={};if(Ue(e)||Object.prototype.toString.call(e)!=="[object Object]")return e;function s(u){const f=Number(u);return isNaN(f)||u.indexOf(".")!==-1||t.object?u:f}function h(u,f,c){return Object.keys(c).reduce(function(p,b){return p[u+n+b]=c[b],p},f)}function l(u){const f=Object.prototype.toString.call(u),c=f==="[object Array]",p=f==="[object Object]";if(u){if(c)return!u.length;if(p)return!Object.keys(u).length}else return!0}return e=Object.keys(e).reduce(function(u,f){const c=Object.prototype.toString.call(e[f]);return!(c==="[object Object]"||c==="[object Array]")||l(e[f])?(u[f]=e[f],u):h(f,u,U(e[f],t))},{}),Object.keys(e).forEach(function(u){const f=u.split(n).map(i);let c=s(f.shift()),p=s(f[0]),b=a;for(;p!==void 0;){if(c==="__proto__")return;const E=Object.prototype.toString.call(b[c]),y=E==="[object Object]"||E==="[object Array]";if(!r&&!y&&typeof b[c]<"u")return;(r&&!y||!r&&b[c]==null)&&(b[c]=typeof p=="number"&&!t.object?[]:{}),b=b[c],f.length>0&&(c=s(f.shift()),p=s(f[0]))}b[c]=Ve(e[u],t)}),a}const cr=Re();let ke;const mr=(e,t,n=!1)=>{const r=lr({...typeof n=="boolean"?null:n,locale:e,messages:fr.flatten(t,{safe:!0})},cr),i=p=>{const b="Invalid Date";if(!p)return b;try{const E=new Date(p*1e3);return
|
|
22
|
+
For more details see https://formatjs.io/docs/getting-started/message-distribution`)}function lr(e,t){var n=Vt(t),r=m(m({},jt),e),i=r.locale,a=r.defaultLocale,o=r.onError;return i?!Intl.NumberFormat.supportedLocalesOf(i).length&&o?o(new Oe('Missing locale data for locale: "'.concat(i,'" in Intl.NumberFormat. Using default locale: "').concat(a,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):!Intl.DateTimeFormat.supportedLocalesOf(i).length&&o&&o(new Oe('Missing locale data for locale: "'.concat(i,'" in Intl.DateTimeFormat. Using default locale: "').concat(a,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):(o&&o(new wt('"locale" was not configured, using "'.concat(a,'" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details'))),r.locale=r.defaultLocale||"en"),hr(r),m(m({},r),{formatters:n,formatNumber:or.bind(null,r,n.getNumberFormat),formatNumberToParts:sr.bind(null,r,n.getNumberFormat),formatRelativeTime:ir.bind(null,r,n.getRelativeTimeFormat),formatDate:Xt.bind(null,r,n.getDateTimeFormat),formatDateToParts:zt.bind(null,r,n.getDateTimeFormat),formatTime:Zt.bind(null,r,n.getDateTimeFormat),formatDateTimeRange:Wt.bind(null,r,n.getDateTimeFormat),formatTimeToParts:qt.bind(null,r,n.getDateTimeFormat),formatPlural:tr.bind(null,r,n.getPluralRules),formatMessage:Ce.bind(null,r,n),$t:Ce.bind(null,r,n),formatList:Kt.bind(null,r,n.getListFormat),formatListToParts:Fe.bind(null,r,n.getListFormat),formatDisplayName:Qt.bind(null,r,n.getDisplayNames)})}var fr=U;U.flatten=U,U.unflatten=Ve;function Ue(e){return e&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function je(e){return e}function U(e,t){t=t||{};const n=t.delimiter||".",r=t.maxDepth,i=t.transformKey||je,a={};function o(s,h,l){l=l||1,Object.keys(s).forEach(function(u){const f=s[u],c=t.safe&&Array.isArray(f),p=Object.prototype.toString.call(f),b=Ue(f),E=p==="[object Object]"||p==="[object Array]",y=h?h+n+i(u):i(u);if(!c&&!b&&E&&Object.keys(f).length&&(!t.maxDepth||l<r))return o(f,y,l+1);a[y]=f})}return o(e),a}function Ve(e,t){t=t||{};const n=t.delimiter||".",r=t.overwrite||!1,i=t.transformKey||je,a={};if(Ue(e)||Object.prototype.toString.call(e)!=="[object Object]")return e;function s(u){const f=Number(u);return isNaN(f)||u.indexOf(".")!==-1||t.object?u:f}function h(u,f,c){return Object.keys(c).reduce(function(p,b){return p[u+n+b]=c[b],p},f)}function l(u){const f=Object.prototype.toString.call(u),c=f==="[object Array]",p=f==="[object Object]";if(u){if(c)return!u.length;if(p)return!Object.keys(u).length}else return!0}return e=Object.keys(e).reduce(function(u,f){const c=Object.prototype.toString.call(e[f]);return!(c==="[object Object]"||c==="[object Array]")||l(e[f])?(u[f]=e[f],u):h(f,u,U(e[f],t))},{}),Object.keys(e).forEach(function(u){const f=u.split(n).map(i);let c=s(f.shift()),p=s(f[0]),b=a;for(;p!==void 0;){if(c==="__proto__")return;const E=Object.prototype.toString.call(b[c]),y=E==="[object Object]"||E==="[object Array]";if(!r&&!y&&typeof b[c]<"u")return;(r&&!y||!r&&b[c]==null)&&(b[c]=typeof p=="number"&&!t.object?[]:{}),b=b[c],f.length>0&&(c=s(f.shift()),p=s(f[0]))}b[c]=Ve(e[u],t)}),a}const cr=Re();let ke;const mr=(e,t,n=!1)=>{const r=lr({...typeof n=="boolean"?null:n,locale:e,messages:fr.flatten(t,{safe:!0})},cr),{$t:i,...a}=r,o=a,s=p=>{const b="Invalid Date";if(!p)return b;try{const E=new Date(p*1e3);return o.formatDate(E,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch{return b}},c={formatUnixTimeStamp:s,formatIsoDate:p=>{const b=Date.parse(p)/1e3;return s(b)},t:(p,b,E)=>o.formatMessage({id:p},b,E),te:p=>!!o.messages[p],tm:p=>o.messages[p]||[],...o,source:t};return(typeof n=="boolean"&&n===!0||typeof n!="boolean"&&n.isGlobal===!0)&&(ke=c),c};function pr(){return ke}const Xe=(e=null)=>w.defineComponent({name:"I18nT",props:{i18n:{type:Object,default:null},keypath:{type:String,required:!0},tag:{type:String,default:"span"}},setup(t,{slots:n}){const r=i=>{if(!i)return[];const a=/(\{[^}]+\})/g;return i.split(a).filter(Boolean)};return()=>{const i=Object.keys(n).filter(s=>s!=="_"),a=(e||t.i18n).messages[t.keypath].toString();let o=r(a);return o=o.filter(s=>s!==""),o.forEach((s,h)=>{if(!s.startsWith("{")&&!s.endsWith("}"))return;const l=s.replace(/[\{\}]/g,"");l==="0"&&n.default?o[h]=n.default():i.includes(l)&&n[l]&&(o[h]=n[l]())}),w.h(t.tag,t,o)}}}),gr={install(e,t){const{i18n:n}=t;e.component("I18nT",Xe(n))}};N.Translation=gr,N.createI18n=mr,N.i18nTComponent=Xe,N.useI18n=pr,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -29,7 +29,7 @@ export declare const i18nTComponent: <MessageSource extends Record<string, any>>
|
|
|
29
29
|
}>>, {
|
|
30
30
|
tag: string;
|
|
31
31
|
i18n: IntlShapeEx<MessageSource>;
|
|
32
|
-
}>;
|
|
32
|
+
}, {}>;
|
|
33
33
|
declare const _default: {
|
|
34
34
|
install<MessageSource extends Record<string, any>>(app: App, options: {
|
|
35
35
|
i18n: IntlShapeEx<MessageSource>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Translation.d.ts","sourceRoot":"","sources":["../../src/Translation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,cAAc;;;;;;;;;;;;;SAoCZ,UAAU;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Translation.d.ts","sourceRoot":"","sources":["../../src/Translation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,cAAc;;;;;;;;;;;;;SAoCZ,UAAU;;;;;;;;;;;;;;;;MAyBvB,CAAA;;4DAIwD,GAAG;;;;AAD7D,wBAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1-pr.618.1de3214.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/i18n.umd.js",
|
|
6
6
|
"module": "./dist/i18n.es.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"errorLimit": "300KB"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"vue": "^3.
|
|
40
|
+
"vue": "^3.3.4"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@formatjs/intl": "^2.9.0",
|