Open BrunoJuchli opened 3 months ago
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.
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
`<FrameworkReference Include="Microsoft.AspNetCore.App" />
and all types that fail to compile then. I've also had to plug in a customizedITranslationProvider
because so as to load the PO files from the web server (viaHttpClient
) 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.