How to work with nested locale folder structures in Vue
dev.to·1d·
Discuss: DEV
Flag this post

Recently, I was working on a Vue-based application where I decided to explore a bit how I could adapt the frontend architecture (or more specifically - the folder structure and the config, in this case) to work with multiple locale/translation files, including nested in other directories.

Getting a single locale JSON file for each language is easy, especially if you work with Vite in your project, but what about multiple files for the same locale/language? Well, it is not that much of a big deal. I played around a bit with different solutions and our beloved ChatGPT has suggested the following approach.

The code

First step is to assign the translation files to a messages variable, and the catch here is, that if you want to assign a name to a specific set of translations (l…

Similar Posts

Loading similar posts...