0
2250368121 created
3 Answer(s)
-
0
- Solution
- How ABP loads localization in a microservice solution
- In the microservice template, the Administration (or LanguageService if dynamic localization is enabled) microservice aggregates localization. All UI/apps get texts from the Application Localization endpoint via the gateway:
- GET /api/abp/application-localization?cultureName=xx
- Each microservice defines its own resources (e.g., BaseSetServiceResource) in its contracts/domain and registers them on startup. The Language Management infrastructure persists/serves these resources to the Administration service, which then responds to the endpoint above.
- If a resource intermittently “disappears” from the Language Texts page or from the dropdown, check:
- The microservice hosting that resource is running and has started successfully.
- The resource assembly is referenced by the microservice host and the resource is added in the module class, for example:
- In the microservice template, the Administration (or LanguageService if dynamic localization is enabled) microservice aggregates localization. All UI/apps get texts from the Application Localization endpoint via the gateway:
[DependsOn(/* ... */)] public class QRSPCBaseSetServiceDomainSharedModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { Configure<AbpLocalizationOptions>(options => { options.Resources .Add<BaseSetServiceResource>("en") .AddBaseTypes(typeof(AbpValidationResource)) .AddVirtualJson("/Localization/BaseSetService"); // folder with zh-Hans.json etc. }); } }3) The gateway routes /api/abp/application-localization to Administration and no cache inconsistency exists (see next). 4) If dynamic localization is enabled, ensure the Language Management DB contains the resource (initial registration occurs on first start of the resource-owning service). Restarting the service re-registers resources if needed.Caching considerations for intermittent missing resources
- The application-localization response is cached by clients while the backend reads from the Language Management store. In clustered deployments, use a distributed cache (e.g., Redis) for consistent results across instances. If you see intermittent visibility:
- Ensure all services (including Administration) share the same distributed cache and database.
- After deploying a new service or changing localization files, recycle the Administration service and clear distributed cache to avoid stale entries.
- Verify the gateway and Administration instances are healthy; a failing instance behind load-balancer may respond without the new resource.
- The application-localization response is cached by clients while the backend reads from the Language Management store. In clustered deployments, use a distributed cache (e.g., Redis) for consistent results across instances. If you see intermittent visibility:
Why the page returns to Home every ~45 minutes
- This is almost always due to authentication/session validation rather than localization. Two common causes:
- Security stamp validation/sign-in cookie validation cycle (for MVC/Angular with OpenIddict/Identity). If the cookie expires or security-stamp validation fails, the UI is redirected to re-authenticate, which brings the app back to its root.
- Access token expiry/refresh failure in SPA: if the token expires and refresh does not happen (or fails), the app reloads and lands on the root.
- What to check:
- Token lifetimes and cookie expiration/SlidingExpiration in your Auth Server configuration. Make sure the Angular/MVC client refreshes tokens correctly and that the allowed clock skew and refresh token settings are configured.
- If running behind a gateway, ensure the issuer configuration (AuthServer:Authority) is correct for all services so validation doesn’t fail when tokens rotate.
- Confirm data protection keys are persisted and shared across instances, otherwise cookies become invalid after key rotation and users get logged out periodically.
- This is almost always due to authentication/session validation rather than localization. Two common causes:
Diagnostics checklist
- Call, via the gateway, while the problem occurs:
- GET /api/abp/application-localization?cultureName=zh-Hans&onlyDynamics=false
- Confirm “resources” includes your BaseSetService resource name.
- Inspect the Administration service logs when the resource is missing; you should see the resource registration on the service startup. If not, verify the module configuration and that the assembly with localization files is loaded by the host.
- Ensure your JSON files are embedded/virtual (Virtual File System) and the path in AddVirtualJson matches the folder name.
- Verify distributed cache and DB connection strings are the same across all instances.
- For the 45-minute refresh:
- Check token/cookie lifetimes in the Auth Server and whether the SPA is performing silent refresh. If necessary, increase lifetimes to confirm the behavior changes, then tune properly.
- Call, via the gateway, while the problem occurs:
- Sources
- https://abp.io/docs/latest/framework/architecture/modularity/basics
- https://abp.io/docs/latest/framework/api-development/standard-apis/localization
- https://abp.io/docs/latest/framework/fundamentals/localization
- https://abp.io/docs/latest/solution-templates/microservice/localization-system
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
你好
请分享下你的整个解决方案的项目结构
谢谢
-
0
你可以检查下数据库的LocalizationResources表.
另外BaseSetService是否直接或者间接依赖了
LanguageManagementDomainModule?

