Localization from the database

Greetings!

Has anyone tried to change default behavior of the IStringLocalizer and store and get string translations from the database?

I've created public class CustomStringLocalizer : IStringLocalizer and registered it in the Startup.cs like:
services.AddLocalization(); services.AddSingleton<IStringLocalizer>(sp => new CustomStringLocalizer());

but for some reason, the app is still using .resx files Radzen created automatically.

So basically, I would like to change the source of the localization strings from .resx files to database table.

Thank you!

Hi @gotik911,

Most probably this code isn't replacing the default implementation or is called to early and gets replaced afterwards. Also Radzen pages use IStringLocalizer<T> instead of IStringLocalizer.

Hi @korchev,

Thank you so much for the quick response. You are right about IStringLocalizer<T>. I implemented it and it works now.

What do you think, is it possible to implement localization string insert into database table of the default culture string when I add it in Radzen (or change the Text property of some control), the same way Radzen do in the .resx files?

No, I am afraid this isn't possible to support.

Thank you! I'll just check the .resx file if the localization is not found in the table. Not sure about performances, but I think it will help a lot until all strings are translated in the db table.

One more time, thank you for your great support!