@kong-ui-public/i18n 0.3.5-pr.231.f2b92ff.0 → 0.4.1

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
@@ -26,7 +26,7 @@ This is a wrapper around [FormatJS](https://formatjs.io/docs/intl) that allows c
26
26
 
27
27
  In order to provide full autocompletion for the translation keys, you need to pass the type of the `messages` object to the various init functions, as shown here:
28
28
 
29
- > **Note**: type checking and autocompletion are still a work-in-progress when utilizing the `i18n-t` component.
29
+ > **Note**: For the `i18n-t` component (`Translation.ts`), the type checking and auto-completion for the `keypath` prop are still a work-in-progress due to [the issue described here](https://github.com/Kong/public-ui-components/pull/231).
30
30
  >
31
31
 
32
32
  ### Global Registration
@@ -37,17 +37,15 @@ import { createI18n, Translation } from '@kong-ui-public/i18n'
37
37
  import english from './locales/en.json'
38
38
 
39
39
  const i18n = createI18n<typeof english>('en-us', english, true)
40
- app.use(Translation, { i18n })
40
+ app.use(Translation.install<typeof english>, { i18n })
41
41
 
42
42
  // composables/index.ts
43
- import { useI18n as useI18nComposable } from '@kong-ui-public/i18n'
43
+ import { useI18n } from '@kong-ui-public/i18n'
44
44
  import english from './locales/en.json'
45
45
 
46
-
47
- const useI18n = useI18nComposable<typeof english>
48
-
49
46
  export default {
50
- useI18n,
47
+ // Be sure to provide the interface when exporting
48
+ useI18n: useI18n<typeof english>,
51
49
  }
52
50
 
53
51
  // Component.vue
@@ -63,7 +61,7 @@ import english from './locales/en.json'
63
61
 
64
62
  const i18n = createI18n<typeof english>('en-us', english, true)
65
63
  const app = createApp(App)
66
- app.use(Translation, { i18n })
64
+ app.use(Translation.install<typeof english>, { i18n })
67
65
 
68
66
  app.mount('#app')
69
67
  ```
@@ -93,7 +91,8 @@ And then, anywhere in application code where `i18n` is needed:
93
91
 
94
92
  <script setup lang="ts">
95
93
  import { useI18n } from '@kong-ui-public/i18n'
96
- const i18n = useI18n()
94
+ import english from './locales/en.json'
95
+ const i18n = useI18n<typeof english>()
97
96
  </script>
98
97
  ```
99
98
 
@@ -151,7 +150,8 @@ const i18n = createI18n<typeof english>(props.locale || 'en-us', english)
151
150
 
152
151
  <script setup lang="ts">
153
152
  import { useI18n } from '@kong-ui-public/i18n'
154
- const i18n = useI18n()
153
+ import english from './locales/en.json'
154
+ const i18n = useI18n<typeof english>()
155
155
  </script>
156
156
  ```
157
157
 
@@ -199,8 +199,9 @@ In `khcp-ui` there are many places where instead of using Intl function we are a
199
199
 
200
200
  <script setup lang="ts">
201
201
  import { useI18n } from '@kong-ui-public/i18n'
202
+ import english from './locales/en.json'
202
203
 
203
- const i18n = useI18n()
204
+ const i18n = useI18n<typeof english>()
204
205
  const helpText = i18n.source.components.docUploadCard
205
206
  </script>
206
207
  ```
@@ -235,7 +236,7 @@ import english from './locales/en.json'
235
236
  //this will create Application instance of Intl object
236
237
  const i18n = createI18n<typeof english>('en-us', english, true)
237
238
  // this will register <i18n-t> component
238
- app.use(Translation, { i18n })
239
+ app.use(Translation.install<typeof english>, { i18n })
239
240
  ```
240
241
 
241
242
  And then, anywhere in application code where `i18n` is needed
package/dist/i18n.es.js CHANGED
@@ -3313,7 +3313,7 @@ const cr = (e = null) => ke({
3313
3313
  },
3314
3314
  keypath: {
3315
3315
  type: String,
3316
- // type: String as unknown as PropType<PathToDotNotation<MessageSource, string>>, // This breaks the type interface
3316
+ // type: String as unknown as PropType<PathToDotNotation<MessageSource, string>>, // This breaks the type interface, enable to debug
3317
3317
  required: !0
3318
3318
  },
3319
3319
  tag: {