Core Architecture
The framework provides comprehensive multilingual capabilities through a hierarchical settings system:
// Language resolution hierarchy
Request Culture (Cookie)
↓ (Not set)
User Preference Setting
↓ (Not set)
Tenant Default Setting
↓ (Not set)
Global Default Setting
↓ (Not set)
Fallback to zh-CN
Backend Implementation
Resource Injection
public class ProductController : ControllerBase
{
private readonly IStringLocalizer<AppResources> _translator;
public ProductController(IStringLocalizer<AppResources> translator)
{
_translator = translator;
}
public IActionResult Get()
{
return Ok(new {
Message = _translator["Product.Saved"].Value
});
}
}
Validation Attributes
public class ProductDto
{
[Required(ErrorMessageResourceType = typeof(ValidationMessages),
ErrorMessageResourceName = "FieldRequired")]
[StringLength(100,
ErrorMessageResourceType = typeof(ValidationMessages),
ErrorMessageResourceName = "MaxLength")]
public string Name { get; set; }
}
Front end Integration
JavaScript Usage
// Get translated text
const successMsg = FrameworkI18n.t('Notifications.Success');
// Switch language
FrameworkI18n.setLanguage('fr');
Razor Components
@inject IStringLocalizer<SharedResources> Locale
<h3>@Locale["Product.Details"]</h3>
Configuration Management
Settings Strucutre
// Global default
Module: "Localization"
Key: "DefaultLanguage"
Value: "en"
Scope: Global
// Tenant override
Module: "Localization"
Key: "DefaultLanguage"
Value: "de"
Scope: Tenant
ScopeId: "tenant123"
// User preference
Module: "Localization"
Key: "PreferredLanguage"
Value: "fr"
Scope: User
ScopeId: "user456"
Navigation Localization
Controller Configuration
[Navigation(
TitleResourceKey = "Modules.Products",
TitleResourceType = typeof(NavResources),
Icon = "fa-box"
)]
public class ProductsController : BaseController
{
// Controller actions
}
Cache Management
// Clear navigation cache
await _navService.ClearCacheAsync();
// Rebuild navigation tree
await _navService.RebuildNavigationAsync();
Extending Languages
Adding New Language
- Add to appsettings.json
- Create resource files (e.g. Sharedd.fr.resx)
- Add AMIS locale file
- Update language selector UI