abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.73k stars 3.4k forks source link

Localization resources in Angular with microservices #4719

Open abxeps opened 4 years ago

abxeps commented 4 years ago

Hi,

How are multiple resource files (from multiple microservices) supposed to be accessed from on angular web application ? Since angular gets its localized texts from a single service call to /api/abp/application-configuration, how can all resources be merged into the response of this call? The microservices are developed as independant abp module solutions.

realLiangshiwei commented 4 years ago

You can get applicaton-configuration from gateway.

See https://github.com/abpframework/abp-samples/tree/master/MicroserviceDemo/gateways/BackendAdminAppGateway.Host

abxeps commented 4 years ago

I saw this approach, does it mean I need to create a dependency (and rebuild the gateway) each time we add new resources to some microservice? like here : https://github.com/abpframework/abp-samples/blob/e21e21d59b76622ce418f270f897cb1ac7369a18/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj#L47

Would have been nice to be less coupled and have the ability for modules to register themselves at startup and send resource informations to the main app or gateway

realLiangshiwei commented 4 years ago

There is currently no such module,you can implement this feature yourself. You can store localized content in a distributed cache and read from the cache.

hikalkan commented 4 years ago

I am adding this to the backlog as an improvement point. But we can't have time to work on this in a short time.

volethanh commented 3 years ago

Hi @realLiangshiwei , how can I override the /api/abp/application-configuration to store and read from the cache as you mentioned ?

It's hurt every time I localize new string and then I have to build gateway again and again.

There is currently no such module,you can implement this feature yourself. You can store localized content in a distributed cache and read from the cache.

realLiangshiwei commented 3 years ago

You can override the GetAsync method

https://github.com/abpframework/abp/blob/8371b74839be57c955d7b6199d1ee10422e4cd26/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs#L69

alexandis commented 3 years ago

Do I get it right, that my issue is not resolvable now? I have Angular module accessing several server-side endpoints. I want to be able to indicate, where I get the resources from. However, all I can do is to supply a resource name, not an appName. And seems like it tries to access any resource from 'default' apiName endpoint, I can't change that:

  localization: {
    defaultResourceName: 'ListSpoolMng'
  }