turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Add support for database store #213

Open jonnybee opened 9 years ago

jonnybee commented 9 years ago

also clean up the cache dependencies and remove System.Web.Caching from ITranslationRepository.

using System.Web.Caching;
    // TODO: this above dependency is unfortunate and should be removed.
    // That would involve a reworking of the design for notifications
    // of languages being modified.
    // GetCacheDependencyForSingleLanguage could be replaced with an event in the Translation
    // object which is signalled when that particular translation becomes dirty.
    // Like wise GetCacheDependencyForAllLanguages could return just an event.
    // It is then down to the client to wrap these events in a custom CacheDependency
    // that monitors the event.
justshrey commented 7 years ago

@turquoiseowl I would like to contribute to this. My understanding is that we would have to essentially create an alternate implementation of ITranslationRepository which implements a backing database store.

Would you like me to create this as a separate Nuget package which can be add-on to this library? Or would you prefer to have a PR to this?

Are there any particular caveats to keep in mind?

turquoiseowl commented 7 years ago

I'd be happy to include your DB implementation alongside the standard POTranslationRepository implementation.

Can't think of any caveats. IIRC others have made their own DB-based implementations -- not sure whether in a fork or private.

justshrey commented 7 years ago

Thank you. 👍 That was a super quick response.

Will get back to you once my fork is ready :)

jonnybee commented 7 years ago

We made our own database repo using EF 6 to enable storage in Oracle, SqlServer and SqlAzure.

You might look into using SqlCacheDependeny. I just ended up caching for a given time and then refresh on a regular basis (fixed intervals).

We have one common master database where translations is done and then export/import into the application database. This did require some extra changes in i18n.PostBuild to configure the database in this applications app.config file while reading the other settings from the actual web applications web.config file (to use different databases).

justshrey commented 7 years ago

Thanks. Will have a look.

I was planning to use an micro-orm ( Dapper ) since having an EF6 instance in this case seems like an unnecessary overhead. Will explore further and see what works best.