@kong-ui-public/i18n 0.2.9-pr.129.9aef2e9.0 → 0.2.9-pr.150.06758e7.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 +56 -1
- package/dist/i18n.es.js +7 -2
- package/dist/i18n.es.js.map +1 -1
- package/dist/i18n.umd.js +9 -9
- package/dist/i18n.umd.js.map +1 -1
- package/dist/types/Translation.d.ts +31 -1
- package/dist/types/Translation.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,6 +161,8 @@ _Please, do not use this method in any new code. This prevents using parameters/
|
|
|
161
161
|
|
|
162
162
|
### HTML safe formatting with `<i18n-t>`
|
|
163
163
|
|
|
164
|
+
#### When registered as Vue Plugin
|
|
165
|
+
|
|
164
166
|
Sometimes it is needed to render translated message with HTML as part of the parameters. For this Provided component can be used.
|
|
165
167
|
|
|
166
168
|
`en.json:`
|
|
@@ -174,7 +176,6 @@ Sometimes it is needed to render translated message with HTML as part of the par
|
|
|
174
176
|
}
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
|
|
178
179
|
`main.ts` (registing component)
|
|
179
180
|
|
|
180
181
|
```ts
|
|
@@ -244,6 +245,60 @@ And then, anywhere in application code where `i18n` is needed
|
|
|
244
245
|
<h1><b>Morning</b>, my name is <i>Val</i>. And I am <i>Money Asker</i>. I want <div class="red">$1,000.00</div></h1>
|
|
245
246
|
```
|
|
246
247
|
|
|
248
|
+
#### With direct use of i18nT component
|
|
249
|
+
|
|
250
|
+
In some cases we do not have access to the Vue `app` and cannot relay on registered i18nT plugin. Working on standalone components in `public-ui-components` is of those cases. And for this your component will look like:
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
```html
|
|
254
|
+
<template>
|
|
255
|
+
<i18n-t
|
|
256
|
+
tag="h1"
|
|
257
|
+
keypath="global.default">
|
|
258
|
+
<a href="https://google.com">Google</a>
|
|
259
|
+
</i18n-t>
|
|
260
|
+
</template>
|
|
261
|
+
|
|
262
|
+
<script setup lang="ts">
|
|
263
|
+
import { createI18n, i18nTComponent } from '@kong-ui-public/i18n'
|
|
264
|
+
import english from './locales/en.json'
|
|
265
|
+
|
|
266
|
+
const i18n = createI18n('en-us', english)
|
|
267
|
+
const i18nT = i18nTComponent(i18n)
|
|
268
|
+
|
|
269
|
+
</script>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Or in old `defineComponent` way
|
|
273
|
+
|
|
274
|
+
```html
|
|
275
|
+
|
|
276
|
+
<template>
|
|
277
|
+
<i18n-t
|
|
278
|
+
:i18n="i18n"
|
|
279
|
+
tag="h1"
|
|
280
|
+
keypath="global.default">
|
|
281
|
+
<a href="https://google.com">Google</a>
|
|
282
|
+
</i18n-t>
|
|
283
|
+
</template>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
<script lang="ts">
|
|
287
|
+
import { defineComponent } from 'vue'
|
|
288
|
+
import { createI18n, i18nTComponent } from '../src'
|
|
289
|
+
import english from './locales/en.json'
|
|
290
|
+
|
|
291
|
+
export default defineComponent({
|
|
292
|
+
components: { i18nT: i18nTComponent() },
|
|
293
|
+
setup() {
|
|
294
|
+
return {
|
|
295
|
+
i18n: createI18n('en-us', english)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
</script>
|
|
300
|
+
```
|
|
301
|
+
|
|
247
302
|
## Formatting numbers, dates and times
|
|
248
303
|
|
|
249
304
|
This comes for free from FormatJS, and documentation on those methods can be found there: [FormatJS](https://formatjs.io/docs/intl)
|
package/dist/i18n.es.js
CHANGED
|
@@ -3304,9 +3304,13 @@ const gr = (e, t, n = !1) => {
|
|
|
3304
3304
|
function pr() {
|
|
3305
3305
|
return Ve;
|
|
3306
3306
|
}
|
|
3307
|
-
const cr = (e) => ke({
|
|
3307
|
+
const cr = (e = null) => ke({
|
|
3308
3308
|
name: "I18nT",
|
|
3309
3309
|
props: {
|
|
3310
|
+
i18n: {
|
|
3311
|
+
type: Object,
|
|
3312
|
+
default: null
|
|
3313
|
+
},
|
|
3310
3314
|
keypath: {
|
|
3311
3315
|
type: String,
|
|
3312
3316
|
required: !0
|
|
@@ -3324,7 +3328,7 @@ const cr = (e) => ke({
|
|
|
3324
3328
|
return i.split(a).filter(Boolean);
|
|
3325
3329
|
};
|
|
3326
3330
|
return () => {
|
|
3327
|
-
const i = Object.keys(n).filter((s) => s !== "_"), a = e.messages[t.keypath].toString();
|
|
3331
|
+
const i = Object.keys(n).filter((s) => s !== "_"), a = (e || t.i18n).messages[t.keypath].toString();
|
|
3328
3332
|
let o = r(a);
|
|
3329
3333
|
return o = o.filter((s) => s !== ""), o.forEach((s, h) => {
|
|
3330
3334
|
if (!s.startsWith("{") && !s.endsWith("}"))
|
|
@@ -3343,6 +3347,7 @@ const cr = (e) => ke({
|
|
|
3343
3347
|
export {
|
|
3344
3348
|
vr as Translation,
|
|
3345
3349
|
gr as createI18n,
|
|
3350
|
+
cr as i18nTComponent,
|
|
3346
3351
|
pr as useI18n
|
|
3347
3352
|
};
|
|
3348
3353
|
//# sourceMappingURL=i18n.es.js.map
|