@kong-ui-public/i18n 0.2.9-pr.129.9aef2e9.0 → 0.2.9-pr.150.1377068.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 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
+ #### With registered i18nPlugin
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,31 @@ 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 vue `app` and cannot relay on registered i18nT plugin. Working on stadalone 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, Translation } from '@kong-ui-public/i18n'
264
+ import english from './locales/en.json'
265
+
266
+ const i18n = createI18n('en-us', english)
267
+ const i18nT = createI18nTComponent(i18n)
268
+
269
+ </script>
270
+
271
+ ```
272
+
247
273
  ## Formatting numbers, dates and times
248
274
 
249
275
  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 createI18nTComponent,
3346
3351
  pr as useI18n
3347
3352
  };
3348
3353
  //# sourceMappingURL=i18n.es.js.map