intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.21k stars 337 forks source link

fix(types): `$t` types #1883

Closed mitjans closed 5 months ago

mitjans commented 5 months ago

This PR addresses 2 problems with Typescript types:

  1. JsonPaths: Will return leaf keys only, and not suggest in-between keys from a JSON or Javascript object. I've called it Json because this should be used when extracting translations from JSON files.

  2. TranslationsPaths: This will simply remove the first level of a JSON or JS object and return the JsonPaths from the second level onwards. This is used for translations coming directly from the composer, where the top-level key is the language.

I've tried not to modify existing types to avoid breaking something, and I just created these 2 new types. Here're two images of the new behavior both in $t and when using the composer: image image