i18n Key Naming for Buttons and Form Labels
Best practices for naming i18n translation keys for buttons, form labels, and interactive elements. Includes conventions for action verbs, confirmation dialogs, and accessible labels.
Detailed Explanation
Naming i18n Keys for Buttons and Labels
Buttons and form labels are the most frequently translated UI elements. Consistent key naming for these elements reduces confusion for translators and makes the codebase easier to maintain.
Button Key Patterns
The most common pattern groups all buttons under a shared namespace:
{
"common": {
"buttons": {
"submit": "Submit",
"cancel": "Cancel",
"save": "Save",
"delete": "Delete",
"edit": "Edit",
"close": "Close",
"confirm": "Confirm",
"back": "Back",
"next": "Next",
"retry": "Retry"
}
}
}
For context-specific buttons, include the context in the key:
{
"checkout": {
"buttons": {
"place_order": "Place Order",
"apply_coupon": "Apply Coupon",
"update_quantity": "Update"
}
}
}
Form Label Patterns
Form labels follow a similar structure, grouped by form or feature:
{
"forms": {
"labels": {
"email": "Email Address",
"password": "Password",
"confirm_password": "Confirm Password",
"first_name": "First Name",
"last_name": "Last Name",
"phone": "Phone Number"
},
"placeholders": {
"email": "you@example.com",
"password": "Enter your password",
"search": "Search..."
}
}
}
Separation of Concerns
Keep these as separate key groups:
- Labels -- the visible text next to or above a form field
- Placeholders -- the hint text inside the field
- Help text -- additional guidance below the field
- Validation messages -- error text when validation fails
- Aria labels -- accessibility text not visible on screen
{
"fields": {
"email": {
"label": "Email Address",
"placeholder": "you@example.com",
"help": "We will never share your email.",
"errors": {
"required": "Email is required.",
"invalid": "Please enter a valid email address."
},
"aria_label": "Enter your email address"
}
}
}
Avoid Generic Keys
Avoid keys like button1, label_a, or text_23. These provide no context to translators and make code reviews difficult. Always use descriptive names that reflect the content or purpose.
Use Case
Button and label keys are the foundation of any translation file. Getting the naming right for these elements prevents painful refactors later. When onboarding new team members or translators, well-named button and label keys make it immediately clear what each string refers to without needing to see the UI.
Try It — i18n Key Generator
Related Topics
i18n Key Naming for Error Messages and Validation
Key Types
i18n Key Naming for Pluralization Rules
Key Types
i18n Key Naming Conventions: Dot Notation, snake_case, and camelCase
Naming Conventions
Organizing i18n Keys with Namespaces and Scopes
Key Structure
Avoiding i18n Key Duplication Across Translation Files
Best Practices