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

Add an option to opt out `$rt` (resolve transition) when using `$tm`

Open Dananz opened this issue 11 months ago • 1 comments

Clear and concise description of the problem

So it all starts with our app in my job, we started it with vue 2 with vue-i18n 2 years ago, and have tons of pages / components that are being in use.

We've decided to upgrade the app and switch to nuxt from the old traditional spa, and while refactoring our app to nuxt, we managed to work with $tm without using $rt for a long time.

And for the latest versions of @nuxtjs/i18n this is not available anymore. You can see this issue I've opened about it in the @nuxtjs/i18n repo

After consulting with @kazupon and @BobbieGoede , i've understood that this behavior is not avilable anymore and we need to refactor alot of components around the app to use $rt.

Im sure that there must be a good reason to why you decided to add $rt in the firstplace, but for some people refactoring from a large scale vue-2 application to nuxt, this could be frightening because this behavior requires alot of changes, and for some other frameworks like react, this behavior does not exists at all.

Suggested solution

I would like to suggest adding an configuration to opt out from this behavior.

something like autoResolveTranslations: true, and you could also mention in the docs that this approach is less performant.

Alternative

Provide a method to precompile large optimized translations to raw objects. this could also have the same effect for some of our implementations at our app.

Or for example: i18next have a simplified api for this, they are using { returnObjects: true } option for objects. Source

Additional context

This is what my app is printing when Im not using $rt (the last object)

image

Validations

Dananz avatar Sep 05 '23 16:09 Dananz