Naming Strings
Every string has a namespace and a key, used together in code as namespace.key. Translators see both, so good names help them understand where a string appears.
Namespace
The namespace is the component, page or feature the text belongs to, in snake_case. For a component, convert its name from PascalCase:
| Component | Namespace |
|---|---|
<MyExampleComponent /> | my_example_component |
| A contact page | contact_page |
The editor groups strings into sections by namespace, so translators can work through one part of the app at a time.
Key
The key says what the text is for, in snake_case. Name it after its purpose, not its current wording, so it stays right when the English is reworded.
{
"example_feature": {
"heading": "Welcome to the feature",
"success_message": "Operation completed successfully."
}
}
<Header title={t("example_feature.heading")} />
Tips
-
Prefer full sentences to fragments. Irish word order differs from English, so a sentence built from several separate strings is often impossible to translate well. Use a placeholder instead:
{ "greeting": "Hello, {{name}}!" } -
Keep placeholders and tags exactly as they are in the English. The editor warns translators if one is missing from the Irish.
-
Don't reuse a string in two places just because the English matches. The same English can need different Irish in different contexts.
-
Renaming a key is safe as long as its English stays the same in that push: the Irish follows it.
Summary
| Element | Convention | Example |
|---|---|---|
| Namespace | snake_case, named after the component or feature | my_example_component |
| Key | snake_case, named after its purpose | success_message, heading |