@kong-ui-public/i18n 2.0.8-pr.1069.ceedeee4.0 → 2.1.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 +20 -1
- package/dist/i18n.es.js +372 -364
- package/dist/i18n.umd.js +9 -9
- package/dist/types/i18n.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -165,6 +165,7 @@ const i18n = createI18n<typeof english>(props.locale || 'en-us', english)
|
|
|
165
165
|
"test": {
|
|
166
166
|
"withParams": "Good {dayPart}, My name is {name}!",
|
|
167
167
|
"withPluralization": "{count} {count, plural, =0 {versions} =1 {version} other {versions}} available"
|
|
168
|
+
"withDateTimeFormatting": "{value, date, datetime}",
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
```
|
|
@@ -181,6 +182,10 @@ const i18n = createI18n<typeof english>(props.locale || 'en-us', english)
|
|
|
181
182
|
{{ i18n.t('test.withPluralization', { count: 0 }) }}
|
|
182
183
|
{{ i18n.t('test.withPluralization', { count: 1 }) }}
|
|
183
184
|
{{ i18n.t('test.withPluralization', { count: 11 }) }}
|
|
185
|
+
With datetime formatting
|
|
186
|
+
{{ i18n.t('test.withDateTimeFormatting', { value: Date.parse('Nov 30, 2023, 11:40 AM') }) }}
|
|
187
|
+
{{ i18n.t('test.withDateTimeFormatting', { value: new Date(0).getTime() }) }}
|
|
188
|
+
{{ i18n.t('test.withDateTimeFormatting', { value: 1701344449607 }) }}
|
|
184
189
|
</template>
|
|
185
190
|
|
|
186
191
|
|
|
@@ -204,6 +209,11 @@ With pluralization:
|
|
|
204
209
|
0 versions available
|
|
205
210
|
1 version available
|
|
206
211
|
11 version available
|
|
212
|
+
|
|
213
|
+
With datetime formatting:
|
|
214
|
+
Nov 30, 2023, 11:40 AM
|
|
215
|
+
Jan 1, 1970, 12:00 AM
|
|
216
|
+
Nov 30, 2023, 11:40 AM
|
|
207
217
|
```
|
|
208
218
|
|
|
209
219
|
### Where is my helpText?
|
|
@@ -387,6 +397,15 @@ Or in old `defineComponent` way
|
|
|
387
397
|
|
|
388
398
|
This comes for free from FormatJS, and documentation on those methods can be found there: [FormatJS](https://formatjs.io/docs/intl)
|
|
389
399
|
|
|
400
|
+
You can use [ICU Message syntax](https://unicode-org.github.io/icu/userguide/format_parse/messages/) with FormatJS and they have a [description of how you can use this syntax within i18n strings](https://formatjs.io/docs/core-concepts/icu-syntax).
|
|
401
|
+
|
|
402
|
+
This plugin includes an additional `datetime` formatter (examples above) which uses the same `Intl.DateTimeFormatOptions` as the below javascript functions for consistency. Date formatting is documented at https://formatjs.io/docs/core-concepts/icu-syntax/#date-type with `datetime` being an additional format element of the argument:
|
|
403
|
+
|
|
404
|
+
- `datetime` format the date as date and time using the same format as `formatIsoDate` e.g. `Sale begins {start, date, datetime}`
|
|
405
|
+
|
|
406
|
+
In the example `Sale begins {start, date, datetime}`, `start` is the value passed into `t` i.e. `t('key.of.string', {start: new Date().toString()})`, `date` is the name of the ICU format we are using, and `datetime` is to tell FormatJS to use the format we have defined as a standard/common format for formatting 'datetimes'.
|
|
407
|
+
|
|
408
|
+
|
|
390
409
|
Unit tests for I18n wrapper in kong-ui/core also has view examples as a references for those.
|
|
391
410
|
[FormatDate](https://github.com/Kong/shared-ui-components/blob/4a1f99d5cee2d4409f4370a9bce2377450a6429d/packages/core/src/useI18n/i18n.spec.ts#L81)
|
|
392
411
|
[FormatNumber](https://github.com/Kong/shared-ui-components/blob/4a1f99d5cee2d4409f4370a9bce2377450a6429d/packages/core/src/useI18n/i18n.spec.ts#L68)
|
|
@@ -475,7 +494,7 @@ returns array values defined for given key
|
|
|
475
494
|
|
|
476
495
|
```ts
|
|
477
496
|
const { tm } = useI18n()
|
|
478
|
-
console.log(
|
|
497
|
+
console.log(tm('global.disabled'))
|
|
479
498
|
```
|
|
480
499
|
|
|
481
500
|
`result:`
|