Akryum / meteor-vite

MIT License
33 stars 16 forks source link

Using Meteor Vite with i18n #37

Open juliandierker opened 1 year ago

juliandierker commented 1 year ago

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?

timsun28 commented 2 weeks ago

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!