i18n-node-2 icon indicating copy to clipboard operation
i18n-node-2 copied to clipboard

Pull translations from external js/json file

Open chrisj12 opened this issue 8 years ago • 3 comments

Currently the translations are loaded from files in the locales directory. Is there a way I can pull in translations from external resource maybe from S3?

chrisj12 avatar Mar 17 '16 12:03 chrisj12

I think this should not be related to the i18n-node-2 package itself. Maybe you could add something that downloads from S3 before loading i18n-node-2

gjuchault avatar May 19 '16 21:05 gjuchault

While I agree that this is not the responsibility of the i18n-node-2 itself, the package should allow the user to override the load function for the locales files, which will then allow any user who does not wish to use the file system to provide their own implementation.

wallali avatar Jun 09 '17 09:06 wallali

I believe you can override the use of the locales directory and pass any object to use for each locale at set up...

https://github.com/jeresig/i18n-node-2#locales

The documentation states:

In this particular case no files will ever be read when doing a translation. This is ideal if you are loading your translations from a different source. Note that no defaultLocale is set when you pass in an object, you'll need to set it yourself.

In this circumstance you can provide any javascript object to use—so you should be able to fetch external JSON files and use them here.

grantschulte avatar Feb 12 '18 18:02 grantschulte