meteor-vite icon indicating copy to clipboard operation
meteor-vite copied to clipboard

Using Meteor Vite with i18n

Open juliandierker opened this issue 1 year ago • 1 comments

Hey. I am still interested in switching to vite. I am concernded a little bit about the i18n behavior since we use meteor i18n universe for our translation files. Is there any way in the vite config I can tell vite to use the meteor i18n package and also to use the given folder structure from my i18n files?

juliandierker avatar Jun 12 '23 09:06 juliandierker

Hi,

I've recently updated my meteor project to 3.0, including moving to vite bundler. (using this fork) and also ran into the same issue you are having.

From what I could find this might have something to do how vite parses json files directly and also splits it. When I looked at the sources tab in chrome I found that it exported all my top level keys separately.

I am not very experience with vite and how this works, but I found a solution that works as follows:

import english from "/imports/i18n/en.i18n.json";
i18n.addTranslations("en", english);

The english variable contained a js object with all my keys and translations that I was able to add like this instead of importing just the .json file

I hope this might help you and if you're still having issues let me know!

timsun28 avatar Aug 02 '24 18:08 timsun28