Ignored Keys
Skip translation for specific keys while preserving their values in the target locale.
When to Use Ignored Keys
Ignore keys for:
- Custom formatting that should be preserved exactly as entered in each locale
- Content that needs to be completely different based on the locale (e.g., region-specific promotions or culturally-adapted content)
Setting Up Ignored Keys
Add the ignoredKeys
array to your bucket configuration in i18n.json
:
{
"buckets": {
"json": {
"include": ["locales/[locale].json"],
"ignoredKeys": [
"metadata/version",
"user/profile",
"temp/debug"
]
},
"yaml": {
"include": ["translations/[locale].yml"],
"ignoredKeys": ["user/content", "draft/items"]
}
}
}
How Ignored Keys Work
During translation processing:
- Ignored keys are excluded from the translation process
- When translating from source to target locales, ignored keys' values in the target locale are preserved
- Values remain exactly as they are in each target locale
Working with Complex Data Structures
Ignored keys supports nested objects and arrays using forward slash (/
) path notation:
{
"ignoredKeys": [
"level1/level2/level3/ignoredValue",
"settings/advanced/debugFlags/0",
"user/generated/content"
]
}
Important: Always use forward slash (
/
) as the separator for nested keys, not dot (.
). This allows ignoring keys that contain dots in their names.
This powerful notation enables you to:
- Ignore deeply nested properties
- Ignore specific array elements using numeric indices
- Ignore entire object subtrees
Examples
Example: Preserving Existing Translations
Source file (en.json
):
{
"common": {
"save": "Save",
"cancel": "Cancel"
},
"homepage": {
"title": "Welcome to our app",
"subtitle": "Get started today"
}
}
Configuration in i18n.json
:
{
"buckets": {
"json": {
"include": ["locales/[locale].json"],
"ignoredKeys": ["common/save", "common/cancel"]
}
}
}
German file before translation (de.json
):
{
"common": {
"save": "CUSTOM VALUE 1",
"cancel": "CUSTOM VALUE 2"
},
"homepage": {
"title": "Welcome to our app",
"subtitle": "Get started today"
}
}
After translation with Lingo.dev:
{
"common": {
"save": "CUSTOM VALUE 1",
"cancel": "CUSTOM VALUE 2"
},
"homepage": {
"title": "Willkommen in unserer App",
"subtitle": "Starten Sie noch heute"
}
}
Notice how the ignored keys (common/save
and common/cancel
) retain their exact values from the target locale ("CUSTOM VALUE 1"
and "CUSTOM VALUE 2"
) while other content is translated. This clearly demonstrates that ignored keys preserve whatever values exist in the target locale, regardless of what they are.
Difference Between Ignored Keys and Locked Keys
- Locked Keys: Preserve the original values from the source locale (e.g., keeping "Save" from English)
- Ignored Keys: Preserve existing values in each target locale (e.g., keeping "CUSTOM VALUE 1" in the example above)
Use ignored keys when you want to maintain locale-specific content that shouldn't be overwritten during translation.