jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

Pull translations from external js/json file #91

Open chrisj12 opened 8 years ago

chrisj12 commented 8 years ago

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?

gjuchault commented 8 years ago

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

wallali commented 7 years ago

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.

grantschulte commented 6 years ago

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.