Custom storage backed and initialization #91
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
no idea if anybody will find this interesting but here are some changes I implemented in order to enable loading from different sources then files. Our application stores all the translation messages as well as the list of supported locales in the database so I came up with this idea how to define custom storage backends without any hard dependencies to specific db drivers or ORMs.
the locales parameter can accept a closure with a callback parameter that is the actual locale that is being loaded.
then i added a reader parameter that recieves 2 parameters - one is the locale from the first function and the second param is the array of locales.
the code bellow is my initialization using sequelize.js.
another feature I have added is support for
%text%
style Symfony placeholders since we are sharing localization data between a Symfony 2 and node application.This call handles the %id% placeholder in the text.
david