- ABP Framework version: v8.0.3
- UI Type: Blazor WASM
- Database System: EF Core (SQL Server)
-
- Tiered (for MVC) or Auth Server Separated (for Angular): microservice
- Exception message and full stack trace:
- Steps to reproduce the issue:
Hi,
I am trying to localize the column names of the exported excel file that happend in GetListAsExcelFileAsync() of any generated ApplicationServices. I've noticed that the StringLocalizer L that is inherited from the base ApplicationService is not workig properly in this method for any other language beside the default "en". Any ideas?
9 Answer(s)
-
0
Hi,
ABP internally uses Miniexcel to export Excel file.
You need to use dynamic column names to support localization https://github.com/mini-software/MiniExcel?tab=readme-ov-file#7-dynamiccolumnattribute
for example:
var config = new OpenXmlConfiguration { DynamicColumns = new DynamicExcelColumn[] { new DynamicExcelColumn("id") {Name = L["Id"]}, new DynamicExcelColumn("name") {Name = L["Name"]}, new DynamicExcelColumn("createdate") {Name = L["Createdate"]}, new DynamicExcelColumn("point") {Name = L["Point"]}, } };
-
0
I know that. You didn't understand the question. The problem is in L, as StringLocalizer. It's not working properly. Try the example that you suggested to localize the colums for different language beside english.
-
0
Hi,
Could you share some code? I will check it.
-
0
Once again. Just try the code you have suggested:
var config = new OpenXmlConfiguration { DynamicColumns = new DynamicExcelColumn[] { new DynamicExcelColumn("id") {Name = L["Id"]}, new DynamicExcelColumn("name") {Name = L["Name"]}, new DynamicExcelColumn("createdate") {Name = L["Createdate"]}, new DynamicExcelColumn("point") {Name = L["Point"]}, } };
I am doing absolutly the same.
-
0
-
0
In my context the LocalizationResource is properly assigned for the Application Service and localization for exporting to excel it's not working. And I have to mention that for microservices template all the application services are inherited from the base class which properly assign the LocalizationResource. I think the problem is in this specific method GetListAsExcelFileAsync() how is called from UI (in my case from Blazor). I reiterate again the L, as StringLocalizer is working properly from any method of the ApplicationService, besides the GetListAsExcelFileAsync.
-
0
Hi,
Sorry, I can confirm this issue. we will fix it.
You can try to update the
DownloadAsExcelAsync
method. for example:private async Task DownloadAsExcelAsync() { var token = (await BooksAppService.GetDownloadTokenAsync()).Token; var remoteService = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultOrNullAsync("Qa") ?? await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultOrNullAsync("Default"); var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name; if(!currentCulture.IsNullOrEmpty()) { currentCulture = "&culture=" + currentCulture; } NavigationManager.NavigateTo($"{remoteService?.BaseUrl.EnsureEndsWith('/') ?? string.Empty}api/app/books/as-excel-file?DownloadToken={token}&FilterText={Filter.FilterText}&Name={Filter.Name}&Title={Filter.Title}{currentCulture}", forceLoad: true); }
-
0
It's still not working properly.
-
0