Skip to content
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

Open
BrunoJuchli opened this issue Mar 19, 2024 · 2 comments
Open

Add Blazor WASM Support for OrchardCore.Localization.Core #15543

BrunoJuchli opened this issue Mar 19, 2024 · 2 comments
Milestone

Comments

@BrunoJuchli
Copy link

BrunoJuchli commented Mar 19, 2024

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:

Error NETSDK1082 : There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'

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 using ContentRootPoFileLocationProvider makes no sense.

Also, for

Describe the solution you'd like

Split the assemblies/ nuget packages so that

  • OrchardCore.Localization.Core
    • provides localization via PortableObjectStringLocalizer
    • possibly features something like LocalizationServiceCollectionExtensions.AddPortableObjectLocalization, but doesn't register ITranslationProvider because how this works depends on where you use it in
  • OrchardCore.Localization.Mvc
    • provides localization via PortableObjectHtmlLocalizer and for data annotations
    • depends on OrchardCore.Localization.Core (to provide PortableObjectStringLocalizer ).
    • provides 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:

  • from file
  • ... option of root dir location
  • from web address

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 customizedITranslationProvider` 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.

@hishamco
Copy link
Member

As you know OC started before Blazor was a thing :) we might investigate into Blazor support, especially for Core APIs

/cc @sebastienros @Skrypt

@Skrypt
Copy link
Contributor

Skrypt commented Mar 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants