[英]Localize a Blazor hosted Webassembly with a databse resource
I try to localize my Blazor hosted Webassembly.我尝试本地化我的 Blazor 托管的 Webassembly。 For this i have created a Database and oriented on the following link:
为此,我创建了一个数据库并针对以下链接:
https://www.ezzylearning.net/tutorial/asp-net-core-localization-from-database https://www.ezzylearning.net/tutorial/asp-net-core-localization-from-database
But the tutorial is for a ASP.NET Core application.但本教程适用于 ASP.NET Core 应用程序。 How can i use this solution in Blazor?
如何在 Blazor 中使用此解决方案?
I following all the steps but in the end i can´t connect the database as a resource to my IStringLocalizer<T> localizer
.我遵循了所有步骤,但最后我无法将数据库作为资源连接到我的
IStringLocalizer<T> localizer
。 How can i achieve that in my client project instead of the usual resx file the database is created via the controller in my server project is used?如何在我的客户端项目而不是通常的 resx 文件中实现这一点,数据库是通过我的服务器项目中的控制器创建的?
You'd need to implement your own version of the IStringLocalizer interface... however you should note that this is really just a shim interface over the ResourceManagerLocalizer, and the ResourceManagerStringLocalizerFactory.您需要实现您自己的 IStringLocalizer 接口版本……但是您应该注意,这实际上只是 ResourceManagerLocalizer 和 ResourceManagerStringLocalizerFactory 上的 shim 接口。 These obviously use the ResourceManager which is where the resx file formats (which get embedded as resources into assemblies) come into it.
这些显然使用 ResourceManager,这是 resx 文件格式(作为资源嵌入到程序集中)进入其中的地方。
So you'd:所以你会:
The .NET Core sources are readily available, so you could implement closely in line with the existing source. .NET Core 源代码现成可用,因此您可以根据现有源代码实现紧密结合。 Just using a DB connection (and CultureInfo handling) in place of the ResourceManager (which already handles CultureInfo lookups).
只需使用数据库连接(和 CultureInfo 处理)代替 ResourceManager(它已经处理 CultureInfo 查找)。
And the Microsoft guide for the ResourceManager Webassembly version (that you should use as your starting point for DB driven)以及 ResourceManager Webassembly 版本的 Microsoft 指南(您应该将其用作 DB 驱动的起点)
https://docs.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-6.0&pivots=webassembly https://docs.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-6.0&pivots=webassembly
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.