Translation Naming Guidelines
Every translation consists of a namespace and a key.
Namespace
The namespace describes the component or feature where the text will be used.
It is derived by converting the component name from PascalCase to snake_case.
Example
Component name:
<MyExampleComponent />
Namespace:
my_example_component
Key
The key identifies a specific text string within the namespace.
It should clearly describe the purpose or meaning of the text.
Keys are written in snake_case.
Example
Namespace:
example_feature
Keys:
{
"success_message": "Operation completed successfully.",
"heading": "Welcome to the feature"
}
success_message— shown when an operation completes successfully.heading— displayed as the main heading of the feature.
Usage Example
<HeaderComponent title={translate("example_feature.heading")} />
Summary
| Element | Convention | Example |
|---|---|---|
| Namespace | snake_case | my_example_component |
| Key | snake_case | success_message, heading |
Use clear, descriptive names for both namespaces and keys to make translations easy to understand and maintain.