antfu-collective / vitesse

🏕 Opinionated Vite + Vue Starter Template
https://vitesse.netlify.app/
MIT License
8.8k stars 932 forks source link

feat: i18n locales lazy loading #482

Closed riderx closed 1 year ago

riderx commented 1 year ago

Description

This PR is related to https://github.com/antfu/vitesse/issues/481 It allows us to lazy load all the translations.

Linked Issues

https://github.com/antfu/vitesse/issues/481

Additional context

I used the doc here: https://kazupon.github.io/vue-i18n/guide/lazy-loading.html and adapted to the way we load i18n in Vitesse, I'm not 100% that the best approach, but that seems to work.

Then I imported a new module to be able to pass to the app the list of the available langs without importing them.

Before :

CleanShot 2023-03-27 at 01 03 29@2x

CleanShot 2023-03-27 at 01 02 58@2x

After :

CleanShot 2023-03-27 at 01 01 48@2x CleanShot 2023-03-27 at 01 03 17@2x

It's tiny in the template.

See the difference in my current app

Before :

CleanShot 2023-03-27 at 01 13 40@2x

CleanShot 2023-03-27 at 01 10 00@2x

After :

CleanShot 2023-03-27 at 01 12 24@2x CleanShot 2023-03-27 at 01 12 15@2x