Category / Section
Why is Localization Problematic When Defined as `Public`?
Published:
Updated:
When IStringLocalizer<Language>
is declared as a public
property, it may lead to conflicts in dependency injection (DI). DI expects a controlled, immutable reference, which is best achieved by defining it as a private readonly
field in the controller.
private readonly Microsoft.Extensions.Localization.IStringLocalizer<Language> _languages;
How Bold Reports Supports Localization:
Bold Reports allows localization of static text, including tooltips, parameter blocks, and dialog text, based on a specified culture. The localization process involves:
- Using the appropriate culture script files.
- Setting the
locale
property in the Report Viewer configuration.
$("#viewer").boldReportViewer({
reportServiceUrl: "https://on-premise-demo.boldreports.com/ReportService/api/Viewer",
serviceAuthorizationToken: token.token_type + " " + token.access_token,
reportPath: '/Sample Reports/Sales Order Detail',
locale: "fr-FR" // Example: French locale
});
Potential Issues with Incorrect Localization Implementation:
- DI Conflicts: Public properties may create multiple instances, leading to unexpected behavior.
- Localization Failures: Incorrect injection can lead to the improper application of translations.
- Performance Issues: Improper DI management can result in unnecessary memory use.