RickStrahl / Westwind.Globalization

Database driven resource localization for .NET applications
544 stars 135 forks source link

Unable to access resources using JavascriptLocalizationResources api endpoint in production #200

Open lvmajor opened 4 years ago

lvmajor commented 4 years ago

Hi there,

I'd like to know if it's possible to use the JavascriptLocalizationResources api endpoint when using the library with Resx as the resource access mode. I am unable to make it work as there is an error when trying to fetch resources in a "Resources" folder, which exists in the development environment, but not in production as the resources get bundled in /fr/.resources.dll, same goes for the other supported languages when deployed to production environment.

This makes it crash when trying to acess the "Resources" folder which does not exist... Any ideas?

Package version: 3.1.0-preview1 from Nuget (https://www.nuget.org/packages/Westwind.Globalization/3.1.0-preview1) Environment: Asp.Net Core 3.1 Url used to access resources: /api/JavaScriptLocalizationResources?ResourceSet=SharedResources&VarName=sharedResources&localeId=@Context.GetRequestCulture().TwoLetterISOLanguageName Resource mode: Resx

Thanks in advance!

lvmajor commented 4 years ago

Ok I'm trying to find the problem and as I can see as of now, it seems to not support embedded resources as it first tries to get the type from the resourceSetName which fails, and then it tries to get the resources from the resource file, which does not exist in production environment as the resources are embedded per official asp.net core documentation

A potential solution would be to publish the actual .resx files, but it would go against the requirements from asp.net core.... Would there be a way to do similar to string localizer and get the resources from the dll?