- ABP Framework version: v7.3.2
- UI Type: Blazor Server
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
I'd like to understand more about the language management module in ABP Commerical. I was under the impression that by using this module, I would not have to create and maintain all the language texts in JSON files. When I add some new UI which needs localization text (without specifying the values in the JSON files), then I can't see that text shown in the language texts screen, regardless of which Resource Name I am filtering by.
So I have three questions:
- Do I really need to define all the language texts in JSON files, and if so, can I just leave the values blank so that they can rather be defined throught the user interface and stored in the database?
- If I define a localization text in the JSON file and then it is updated using the language management module, how does the framework know which source to use (JSON or database)?
- Is there a way for me to define these localization texts in a more strongly-typed way using C# instead of JSON?
4 Answer(s)
-
0
Hi shaynevanasperen,
- Yes you need to define all the language texts in JSON file, then only it will be available in language management module UI. Yes you can leave the text blank in JSON so that you can add Target Culture Value from UI.
- The framework will take the updated value that is saved from UI.
- As if now framework is handling data from JSON, but you can handle that texts as blank in JSON and can be updated from UI.
-
0
You can actually add language texts through the following methods without the need to add them in JSON.
However, it is still hoped that abp can be provided for adding them from the frontend UI.
var text = (await LanguageTextRepository.GetListAsync()).FirstOrDefault(l => l.CultureName == input.CultureName && l.ResourceName == input.ResourceName && l.Name == input.Name); if (text == null) { await LanguageTextRepository.InsertAsync( new LanguageText(GuidGenerator.Create(), input.ResourceName, input.CultureName, input.Name, input.Value, CurrentTenant?.Id) ); } else { text.Value = input.Value; await LanguageTextRepository.UpdateAsync(text); }
-
0
Okay, thanks. I was hoping that there would be a way for me to avoid "magic" strings in my code. For example, I would rather write this:
L[MyApplicationResource.Companies.ConfirmDelete]
which relies on nested static classes withconst string
properties,than this:
L["Companies:ConfirmDelete"]
which relies on the same "magic" string appearing in my localization JSON files.Can somebody whos is resonsible for the commercial modules architecture/design tell me how they intend to avoid the problem of "magic" strings? A large application could easily accumulate lots of bugs over time without a way to make the localization more strongly typed. Can this be made into an official feature request?
-
0
@enis could you help