@kong-ui-public/i18n 0.6.2-pr.616.b4ff420.0 → 0.7.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 +4 -7
- package/dist/i18n.es.js +12 -12
- package/dist/i18n.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,8 +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
|
-
- [
|
|
16
|
-
- [
|
|
15
|
+
- [formatUnixTimeStamp](#formatunixtimestamp)
|
|
16
|
+
- [formatIsoDate](#formatisodate)
|
|
17
17
|
- [te](#te)
|
|
18
18
|
- [tm](#tm)
|
|
19
19
|
|
|
@@ -397,7 +397,7 @@ Every single method listed in [FormatJS](https://formatjs.io/docs/intl) is expos
|
|
|
397
397
|
|
|
398
398
|
(as previously exposed by vue18n-n)
|
|
399
399
|
|
|
400
|
-
###
|
|
400
|
+
### formatUnixTimeStamp
|
|
401
401
|
|
|
402
402
|
Formats a unix timestamp into a formatted date string
|
|
403
403
|
|
|
@@ -406,7 +406,6 @@ Formats a unix timestamp into a formatted date string
|
|
|
406
406
|
```ts
|
|
407
407
|
const { formatUnixTimeStamp } = useI18n()
|
|
408
408
|
console.log(formatUnixTimeStamp('1558006979'))
|
|
409
|
-
console.log()
|
|
410
409
|
```
|
|
411
410
|
|
|
412
411
|
`result:`
|
|
@@ -415,7 +414,7 @@ console.log()
|
|
|
415
414
|
May 16, 2019, 11:42 AM
|
|
416
415
|
```
|
|
417
416
|
|
|
418
|
-
###
|
|
417
|
+
### formatIsoDate
|
|
419
418
|
|
|
420
419
|
Format an ISO formatted date
|
|
421
420
|
|
|
@@ -424,7 +423,6 @@ Format an ISO formatted date
|
|
|
424
423
|
```ts
|
|
425
424
|
const { formatIsoDate } = useI18n()
|
|
426
425
|
console.log(formatIsoDate('2019-05-16T11:42:59.000Z'))
|
|
427
|
-
console.log()
|
|
428
426
|
```
|
|
429
427
|
|
|
430
428
|
`result:`
|
|
@@ -450,7 +448,6 @@ check if translation message exists
|
|
|
450
448
|
```ts
|
|
451
449
|
const { te } = useI18n()
|
|
452
450
|
console.log({p: te('global.ok'), n: te('global.not.ok')})
|
|
453
|
-
console.log()
|
|
454
451
|
```
|
|
455
452
|
|
|
456
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"})});
|