xiCO2k / laravel-vue-i18n

Allows to connect your `Laravel` Framework translation files with `Vue`.
MIT License
584 stars 49 forks source link

feat: avoid displaying the key until loading #170

Closed rozsazoltan closed 2 months ago

rozsazoltan commented 4 months ago

If the page is not loaded based on SSR, then when the language file loading takes even slightly longer than the rest of the frontend, the key briefly appears for a very short time. This creates a sensation of "vibration". It would be much better if the wTrans (and other dependent functions) function returned nothing until the loading is complete.

I've made a video (not the most professional, but it illustrates the difference), playing back the loading process at 0.1x speed.

https://github.com/xiCO2k/laravel-vue-i18n/assets/67325669/cab5a542-2e26-4707-a1c7-429d1ff533f6

rozsazoltan commented 4 months ago

Hm, GitHub won't let me place the PR in Draft. The implementation is still half-done / incomplete.

Maybe we should complement it with another global setting, which by default allows displaying the key.

showKeyWhileLoading = true // (default)

And for a false value, it would return an empty string.

Althought displaying the key would only be advantageous in the main (99% English) language, and only in cases where the key covers entire words/sentences that are meaningful on their own, rather than just a structure like section.example.key.to.text.

xiCO2k commented 4 months ago

this is a breaking change :(

I could consider that if we make that an option like: hiddenBeforeLoaded, that way we can have this on a Minor Release.

Thanks for the PR.