[Design Discussion] i18n support #927
Replies: 3 comments
-
|
Thinking further about Is harder to deal with on the frontend than |
Beta Was this translation helpful? Give feedback.
-
|
The overall design looks great. Find my input for the Technical Questions
I think with namespacing will be more clear. Then I would expect this namespacing seperation will be API request and response as well. So that it can be easily managed. For the Function style vs Object style, we need to align with the discussion in #812 (comment)
yes, we need to support it. As the saying goes in software design, “There are only three numbers: 0, 1, and many.”. So we should support pluralizations
This is something nice to have. The use case might be if anyone want to use Thunder to manage their application content localisation too. Regarding the Package Structure, can't we have Translation Management API also within the system package ? (as core and mgt sub packages) We need to make sure that the |
Beta Was this translation helpful? Give feedback.
-
Implementation UpdateCurrent StatusA base version of the i18n support has been implemented in PR #940.
Implementation DeviationsThe implementation deviates slightly from the original proposal in the following areas:
Message CategoriesDuring implementation, we identified three distinct types of i18n messages:
Handling Strategy:
Ease of Adoption by Message Type1. Backend Compile-time MessagesStatus: ✅ Fully Covered
2. Frontend Compile-time MessagesStatus:
3. Runtime MessagesStatus:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Related Feature Issue
#876
Problem Summary
Thunder backend needs internationalization (i18n) support to:
Currently, all user-facing strings are hardcoded in English.
Proposed Approach
Overview
i18n.Message{Key, DefaultValue}i18nmetadata section with translation keysi18nsectionBackward Compatible Response Format
All API responses (errors and non-errors) use an optional
i18nmetadata section:Error response:
{ "code": "USR-1001", "message": "User not found", "description": "The user with the specified ID does not exist", "i18n": { "message": "error.user.not_found", "description": "error.user.not_found.description" } }Non-error response:
{ "id": "schema-123", "name": "Employee", "displayName": "Employee Schema", "i18n": { "displayName": "userschema.employee.display_name" } }Key benefits:
i18nsection mirrors parent structure (same field names)i18ni18nsection, new clients use it for translationHow It Works
1. Developer defines an i18n message:
2. Build-time extraction generates defaults.go:
This runs an AST parser that finds all
i18n.Message{}literals and generates:3. Handler builds response with i18n metadata:
4. Frontend fetches language bundle and translates keys from
i18nsection.Bundle Generation Logic
Technical Questions for Discussion
1. i18n Key Format
With namespacing:
Option A - Function style:
Option B - Object style:
Without namespacing:
Option C - Function style:
Option D - Object style:
Questions:
2. Templating Support in i18n Messages
Should we support variable interpolation in messages?
Example:
Bundle response:
{ "error.user.age.invalid": "Age must be between {{min}} and {{max}}" }API response:
{ "message": "Age must be between 10 and 18", "i18n": { "message": { "key": "error.user.age.invalid", "params": { "min": "10", "max": "18" } } } }Frontend usage:
Questions:
3. Custom Keys Support
Should we allow administrators to create translation keys that don't exist in the codebase?
Questions:
Alternative Approaches
1. Server-Side Translation
Accept-Languageheader / query param processing2. Translation Files (JSON/YAML)
3. Alternative approach for bundle API
Architecture and Components
Package Structure
Database Schema
New table to store translations in
thunderdb:API Endpoints
/i18n/bundle/{language}/translations/translations/translations/{key}/{language}/translations/{key}/{language}/translations/{key}/{language}/translations/bulkSecurity Considerations
en,es,fr-CA)Implementation Complexity
Medium (3-6 weeks)
Areas of Thunder that will be impacted
System-wide
Questions for Community Input
Beta Was this translation helpful? Give feedback.
All reactions