vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

feat!: type-safe messages

Open GalacticHypernova opened this issue 1 year ago • 19 comments
trafficstars

Closes #1124 Closes https://github.com/nuxt-modules/i18n/issues/1753

This PR adds type safety for message translations when used with helpers like t().

The reason it's a breaking change is because it's more strict, which could bring some edge case bugs with non-existent messages.

It is a draft for now because there is much work I need to do to get it to work.

Benefits:

This allows for much safer and convenient locale message translation by providing autocomplete suggestions to make sure no typos are present. Essentially a very useful DX update.

Related: #1648 (Had to redo a certain part of the PR so decided to re-open it)

Proof-of-concept:

Smaller object: image Bigger object image image

Performance implications:

None. As with the proof of concept, we have tested (with @BobbieGoede) the performance on extremely large objects. (Tested with core.js package-lock.json file). The results were pretty much instant and no performance downgrade has been detected, view video in the attached folder below: Video.zip (Video was too big and I couldn't get it to save a trimmed version, while testing with Bobbie I had experienced the same issue and had to send the same zip file, apologies in advance!)

Important note

I do not know how to generate unit tests for it, I'm still looking into it.

GalacticHypernova avatar Nov 30 '23 18:11 GalacticHypernova