A comprehensive .NET 9.0 localization management system for SELISE Blocks applications. This solution provides a robust API and background worker services for managing translation keys, languages, modules, and facilitating multi-language support across applications.
- Overview
- Architecture
- Features
- Technology Stack
- Solution Structure
- API Endpoints
- Background Workers
- UILM Format
- Key Timeline
- Getting Started
- Configuration
- Development
- Testing
- Deployment
- Contributing
- License
L2 Net Blocks Localization is a production-ready localization management platform that enables:
- Centralized Translation Management: Manage translation keys, languages, and modules through RESTful APIs
- Multi-Format Import/Export: Support for JSON, CSV, and Excel (XLSX) formats
- AI-Powered Translation: Integration with AI services for translation suggestions
- Event-Driven Processing: Asynchronous background processing for heavy operations
- Version Control: Complete audit trail with key timeline tracking
- Rollback Capabilities: Revert to previous key states
- Multi-Tenant Support: Project-based isolation and management
The solution follows a clean architecture pattern with clear separation of concerns:
βββββββββββββββββββ
β API Layer β β RESTful API Controllers
βββββββββββββββββββ€
β Domain Service β β Business Logic & Services
βββββββββββββββββββ€
β Repositories β β Data Access Layer (MongoDB)
βββββββββββββββββββ€
β Background β β Event Consumers & Workers
β Workers β
βββββββββββββββββββ
- Repository Pattern: Abstraction layer for data access
- Service Layer: Business logic encapsulation
- Event-Driven Architecture: Asynchronous processing via message queues
- Dependency Injection: Loose coupling and testability
- Multi-Tenant Architecture: Project-based data isolation
- β Key Management: Create, read, update, delete, and query translation keys
- β Language Management: Manage supported languages and set default language
- β Module Management: Organize keys into logical modules
- β Bulk Operations: Save multiple keys in a single operation
- β Advanced Filtering: Query keys by module, language, translation status, and more
- β Pagination: Efficient handling of large datasets
- β UILM File Generation: Generate localization files for frontend consumption
- β Multi-Format Support: JSON, CSV, Excel (XLSX) import/export
- β Selective Export: Export specific modules or all modules
- β Incremental Import: Update existing keys without replacing entire datasets
- β AI Translation Suggestions: Get AI-powered translation recommendations
- β Bulk Translation: Translate all missing translations automatically
- β Selective Translation: Translate specific keys on demand
- β Translation Status Tracking: Identify partially translated keys
- β Key Timeline: Complete audit trail of all key changes
- β Rollback Functionality: Revert keys to previous states
- β Environment Data Migration: Migrate localization data between environments
- β Collection Management: Administrative tools for data cleanup
- β Health Checks: Built-in health monitoring endpoints
- .NET 9.0: Latest .NET framework
- ASP.NET Core: Web API framework
- MongoDB: NoSQL database for flexible schema
- Blocks.Genesis: SELISE Blocks framework integration
- FluentValidation: Input validation
- ClosedXML: Excel file generation
- CsvHelper: CSV file processing
- Newtonsoft.Json: JSON serialization
- xUnit: Unit testing framework
l2-net-blocks-localization/
βββ src/
β βββ Api/ # Web API project
β β βββ Controllers/ # API controllers
β β βββ Program.cs # Application entry point
β β βββ ServiceRegistry.cs # Dependency injection
β β
β βββ DomainService/ # Business logic layer
β β βββ Repositories/ # Data access layer
β β βββ Services/ # Business services
β β βββ Shared/ # Shared models and utilities
β β βββ Validation/ # FluentValidation validators
β β
β βββ Worker/ # Background worker project
β β βββ Consumers/ # Event consumers
β β βββ Program.cs # Worker entry point
β β βββ ServiceRegistry.cs # Worker DI configuration
β β
β βββ XUnitTest/ # Unit tests
β
βββ config/ # Configuration files
βββ Dockerfile # Docker configuration
βββ README.md # This file
ASP.NET Core Web API providing RESTful endpoints for localization management.
Key Controllers:
KeyController: Translation key operationsLanguageController: Language managementModuleController: Module managementAssistantController: AI translation suggestions
Core business logic and data access layer.
Key Services:
KeyManagementService: Key CRUD and business logicLanguageManagementService: Language operationsModuleManagementService: Module operationsAssistantService: AI integration
Repositories:
KeyRepository: Key data accessKeyTimelineRepository: Timeline data accessLanguageRepository: Language data accessModuleRepository: Module data access
Background service for asynchronous processing.
Event Consumers:
GenerateUilmFilesConsumer: Generate UILM filesTranslateAllEventConsumer: Bulk translation processingTranslateBlocksLanguageKeyEventConsumer: Single key translationUilmImportEventConsumer: File import processingUilmExportEventConsumer: File export processingEnvironmentDataMigrationEventConsumer: Data migration
POST /Key/Save
Authorization: Bearer {token}
Content-Type: application/json
{
"keyName": "welcome.message",
"moduleId": "auth-module",
"resources": [
{
"culture": "en",
"value": "Welcome!"
},
{
"culture": "fr",
"value": "Bienvenue!"
}
],
"projectKey": "your-project-key"
}POST /Key/SaveKeys
Authorization: Bearer {token}
Content-Type: application/json
[
{
"keyName": "key1",
"moduleId": "module1",
"resources": [...]
},
{
"keyName": "key2",
"moduleId": "module1",
"resources": [...]
}
]POST /Key/Gets
Authorization: Bearer {token}
Content-Type: application/json
{
"moduleId": "auth-module",
"languageCode": "en",
"isPartiallyTranslated": false,
"pageSize": 20,
"pageNumber": 1,
"projectKey": "your-project-key"
}GET /Key/Get?ItemId={keyId}&ProjectKey={projectKey}
Authorization: Bearer {token}DELETE /Key/Delete?ItemId={keyId}&ProjectKey={projectKey}
Authorization: Bearer {token}GET /Key/GetTimeline?PageSize=10&PageNumber=1&EntityId={keyId}&ProjectKey={projectKey}
Authorization: Bearer {token}POST /Key/RollBack
Authorization: Bearer {token}
Content-Type: application/json
{
"itemId": "key-item-id",
"timelineItemId": "timeline-item-id",
"projectKey": "your-project-key"
}POST /Language/Save
Authorization: Bearer {token}
Content-Type: application/json
{
"languageName": "English",
"languageCode": "en",
"isDefault": true,
"projectKey": "your-project-key"
}GET /Language/Gets?ProjectKey={projectKey}DELETE /Language/Delete?LanguageName={languageName}&ProjectKey={projectKey}
Authorization: Bearer {token}POST /Language/SetDefault
Authorization: Bearer {token}
Content-Type: application/json
{
"languageName": "English",
"projectKey": "your-project-key"
}POST /Module/Save
Authorization: Bearer {token}
Content-Type: application/json
{
"moduleName": "authentication",
"moduleId": "auth-module",
"projectKey": "your-project-key"
}GET /Module/Gets?ProjectKey={projectKey}POST /Key/GenerateUilmFile
Authorization: Bearer {token}
Content-Type: application/json
{
"moduleId": "auth-module",
"projectKey": "your-project-key"
}GET /Key/GetUilmFile?Module={moduleName}&Language={languageCode}&ProjectKey={projectKey}POST /Key/UilmExport
Authorization: Bearer {token}
Content-Type: application/json
{
"moduleIds": ["module1", "module2"],
"outputFormat": "JSON",
"projectKey": "your-project-key"
}POST /Key/UilmImport
Authorization: Bearer {token}
Content-Type: application/json
{
"fileId": "file-id-from-storage",
"projectKey": "your-project-key"
}GET /Key/GetUilmExportedFiles?PageSize=10&PageNumber=1&ProjectKey={projectKey}
Authorization: Bearer {token}POST /Key/TranslateAll
Authorization: Bearer {token}
Content-Type: application/json
{
"moduleId": "auth-module",
"projectKey": "your-project-key"
}POST /Key/TranslateKey
Authorization: Bearer {token}
Content-Type: application/json
{
"keyId": "key-item-id",
"targetLanguageCode": "fr",
"projectKey": "your-project-key"
}POST /Assistant/GetTranslationSuggestion
Authorization: Bearer {token}
Content-Type: application/json
{
"sourceText": "Welcome to our application",
"sourceLanguage": "en",
"targetLanguage": "fr",
"projectKey": "your-project-key"
}POST /Key/DeleteCollections
Authorization: Bearer {token}
Content-Type: application/json
{
"collections": ["BlocksLanguageKeys", "BlocksLanguages"],
"projectKey": "your-project-key"
}Note: This endpoint is hidden from API documentation and should be used with extreme caution.
The Worker project processes events asynchronously to handle resource-intensive operations:
- GenerateUilmFilesEvent: Generates UILM files for frontend consumption
- TranslateAllEvent: Processes bulk translation requests
- TranslateBlocksLanguageKeyEvent: Processes single key translation
- UilmImportEvent: Handles file import operations
- UilmExportEvent: Handles file export operations
- EnvironmentDataMigrationEvent: Migrates data between environments
API Request β Event Published β Worker Consumer β Processing β Notification Published
UILM (User Interface Localization Module) is a JSON-based format for storing localization data. The system generates UILM files that can be consumed by frontend applications.
{
"welcome.message": "Welcome!",
"auth.login": "Login",
"auth.logout": "Logout",
"common.buttons.save": "Save",
"common.buttons.cancel": "Cancel"
}The system supports nested keys using dot notation:
{
"common": {
"buttons": {
"save": "Save",
"cancel": "Cancel"
}
}
}A special "key" language mode generates files where values are the same as keys, useful for development and testing.
The Key Timeline feature provides a complete audit trail of all changes to translation keys.
- Change Tracking: Records all create, update, and delete operations
- State Comparison: Shows both current and previous states
- User Attribution: Tracks who made each change
- Timestamp Tracking: Records when changes occurred
- Source Tracking: Identifies the source of changes (API endpoint, import, etc.)
{
"itemId": "timeline-entry-id",
"entityId": "key-item-id",
"currentData": { /* Current key state */ },
"previousData": { /* Previous key state */ },
"logFrom": "KeyController.Save",
"userId": "user-id",
"createDate": "2024-01-15T10:30:00Z"
}- Audit Compliance: Track all changes for compliance requirements
- Debugging: Identify when and why translations changed
- Rollback: Revert to previous key states
- Analytics: Analyze translation change patterns
- .NET 9.0 SDK
- MongoDB instance
- Azure Key Vault (for secrets management)
- SELISE Blocks Genesis framework access
-
Clone the repository
git clone <repository-url> cd l2-net-blocks-localization
-
Restore NuGet packages
dotnet restore src/L2-Net-Blocks-Localization.sln
-
Configure application settings
- Update
appsettings.jsonfiles in Api and Worker projects - Configure MongoDB connection strings
- Set up Azure Key Vault credentials
- Update
-
Build the solution
dotnet build src/L2-Net-Blocks-Localization.sln
-
Run the API
cd src/Api dotnet run -
Run the Worker (in a separate terminal)
cd src/Worker dotnet run
The solution uses environment-specific configuration files:
appsettings.json: Base configurationappsettings.Development.json: Development environmentappsettings.dev.json: Dev environmentappsettings.stg.json: Staging environmentappsettings.prod.json: Production environment
- MongoDB Connection: Database connection strings
- Azure Key Vault: Secret management configuration
- Message Queue: Event bus configuration (via Blocks.Genesis)
- Storage: File storage configuration
- AI Services: Translation service API keys
ASPNETCORE_ENVIRONMENT: Environment name (Development, Staging, Production)port: API port number (default: 80)
- Controllers: Handle HTTP requests and responses
- Services: Contain business logic
- Repositories: Handle data access
- Validators: Input validation using FluentValidation
- Events: Domain events for async processing
- Follow C# coding conventions
- Use async/await for all I/O operations
- Implement proper error handling
- Add XML documentation comments for public APIs
- Use dependency injection for all dependencies
- Create models in
DomainService/Sharedor appropriate service folder - Add repository methods if needed
- Implement service logic
- Create controller endpoints
- Add validators
- Register services in
ServiceRegistry - Write unit tests
cd src/XUnitTest
dotnet test- Unit tests for services
- Integration tests for repositories
- API endpoint tests
The solution includes a Dockerfile for containerized deployment:
docker build -t blocks-localization-api --build-arg git_branch=Production .
docker run -p 8080:80 blocks-localization-apiThe Dockerfile supports environment-specific builds using the git_branch argument:
docker build -t blocks-localization-api --build-arg git_branch=stg .- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code patterns and conventions
- Add unit tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
- Use meaningful commit messages