Using .yml file instead of .json file for translations #140
-
Hi community, I am struggling to use yml files instead of json files for the translations. I defined the yml file in the same place as I defined the json file and just changed the file ending to .yml file in the entry.client.tsx file. Apart from this, I followed the setup as described. Is that in general possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
From what I've seen, i18next only supports JSON files by default. If that isn't at all possible for some reason, you could use something like the i18next-resources-to-backend plugin to use a function to load your YML resource, parse it, and return the output as JSON. The wouldn't be the most performant solution though. Update: If you're using Webpack, you might be able to use something like the js-yaml-loader (disclaimer, I just found this through search, I haven't tested it in any way). |
Beta Was this translation helpful? Give feedback.
From what I've seen, i18next only supports JSON files by default.
I'd suggest finding a way to use JSON files instead, so the i18next plugins continue to work out of the box. Maybe something at build time that scans a folder with the YML files and outputs the equivalent JSON files for run-time use.
If that isn't at all possible for some reason, you could use something like the i18next-resources-to-backend plugin to use a function to load your YML resource, parse it, and return the output as JSON. The wouldn't be the most performant solution though.
Update: If you're using Webpack, you might be able to use something like the js-yaml-loader (disclaimer, I just found this through search, I h…