-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Blazor WASM Support for OrchardCore.Localization.Core #15543
Labels
Milestone
Comments
As you know OC started before Blazor was a thing :) we might investigate into Blazor support, especially for Core APIs /cc @sebastienros @Skrypt |
You can create a Pull Request with your suggested changes that will be easier to review. Then, also, what @hishamco said. This was not designed with Blazor in mind as it happened after. |
This was referenced Apr 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
After installing
OrchardCore.Localization.Core
into a .net 8 Blazor WASM project I get the following error:This is due to the
<FrameworkReference Include="Microsoft.AspNetCore.App" />
in the csproj.Without this reference, there is no
HtmlLocalizer
and also no data annotations localization - these are not supported in Blazor WASM.Furthermore, the setup in
LocalizationServiceCollectionExtensions.AddPortableObjectLocalization
doesn't work for Blazor WASM since - as far as I found - it doesn't support local files. So usingContentRootPoFileLocationProvider
makes no sense.Also, for
Describe the solution you'd like
Split the assemblies/ nuget packages so that
OrchardCore.Localization.Core
PortableObjectStringLocalizer
LocalizationServiceCollectionExtensions.AddPortableObjectLocalization
, but doesn't registerITranslationProvider
because how this works depends on where you use it inOrchardCore.Localization.Mvc
PortableObjectHtmlLocalizer
and for data annotationsOrchardCore.Localization.Core
(to providePortableObjectStringLocalizer
).LocalizationServiceCollectionExtensions
(move them here).Describe alternatives you've considered
Varying on what I've wrote above, the aspect of where is the PO file retrieved from could made pluggable, and a choice of:
could be offered.
Notes
As an experiment, I've removed the ``
and all types that fail to compile then. I've also had to plug in a customized
ITranslationProvider` because so as to load the PO files from the web server (via `HttpClient`) instead of from a local file (I don't think these are availabel in Blazor WASM - at least i couldn't find a way to include these...).This way I got it working.
The text was updated successfully, but these errors were encountered: