Fix "Too Many Translation Keys" Error Step by Step
In this article
This guide shows you exactly how to resolve the “Too Many Translation Keys” error, which typically appears in content management systems, translation management platforms, or custom localization setups when your project exceeds a set limit of translatable strings. By following these steps, you will identify the cause, reduce or reorganize your keys, and prevent the error from recurring.
What You'll Need
- Access to your project's translation files (e.g., .json, .po, .xliff, or database entries)
- Admin or developer permissions to edit translation settings or code
- A text editor or your CMS's built-in translation interface
- Basic understanding of how your app loads translation keys (optional but helpful)
Step-by-Step
- Locate the error source. Check your server logs, error console, or the translation platform's dashboard. The error message usually names the file or module where the limit is exceeded. Note the exact limit number (e.g., 10,000 keys) and your current count.
- Count your current translation keys. If you use JSON files, open them and count the top-level keys. For .po files, count the
msgidentries. In a database-driven system, run a query to count rows in the translation table. Write down the total. - Identify unused or duplicate keys. Search your codebase for each key. Use a script or manual search to find keys that are never referenced in your templates or JavaScript. Also look for duplicate keys—same key defined in multiple files or with different casing (e.g.,
welcome.messagevswelcome.Message). - Remove unused keys. Delete any keys that are not used anywhere. Be careful: a key might be used dynamically (e.g., built from a variable). If you are unsure, test the app after removal.
- Merge duplicate keys. If you have similar keys like
btn.saveandbutton.save, consolidate them into one. Update all references to point to the single key. - Combine keys with parameters. Instead of having separate keys for
greeting.morning,greeting.afternoon, andgreeting.evening, use one key likegreeting.timewith a parameter:"Good {timeOfDay}!"and pass the value dynamically. - Reduce pluralization keys. Many systems require separate keys for singular and plural forms. If your platform supports ICU MessageFormat or similar, use a single key with plural rules instead of multiple keys.
- Split into namespaces or modules. If your system allows segmented translation files (e.g., per page or component), move some keys into separate files. This reduces the count in each file and may bypass the limit if the limit is per-file.
- Increase the limit (if possible). Check your translation platform's settings or your code configuration. Some systems allow you to raise the maximum number of keys. If you have a legitimate need for more keys, upgrade your plan or adjust the configuration.
- Implement lazy loading. If your app loads all translations at startup, switch to loading only the translations needed for the current view or language. This reduces the runtime key count, even if the total file still has many keys.
- Use a translation key naming convention. Establish a clear pattern (e.g.,
feature.element.action) to avoid accidental duplicates and make it easier to spot unused keys in the future. - Re-test after changes. After removing or merging keys, run your app and verify that all text appears correctly. Check both the default language and at least one other language to ensure no missing translations.
Common Mistakes
- Deleting keys that are used dynamically. Keys generated at runtime (e.g.,
t('error.' + code)) are easy to miss. Always search for partial matches or use a regex to find patterns. - Merging keys with different meanings. Two keys might look similar but have different context (e.g.,
saveas a verb vssaveas a noun). Only merge if the meaning is identical. - Ignoring language-specific requirements. Some languages have different plural forms or gender agreements. Removing plural keys without using proper pluralization rules can break translations.
- Changing keys without updating references. If you rename a key, you must update every place it is used. Use find-and-replace carefully.
- Not checking the limit scope. The limit might be per project, per file, or per language. Make sure you know which one you are hitting.
Tips
- Write a simple script to list all keys and their usage count. This makes it easy to spot unused keys.
- Use a translation management tool that automatically detects unused keys (e.g., Lokalise, Phrase, or Crowdin have such features).
- Keep keys short but descriptive. Long keys take up space and increase the chance of typos.
- Regularly audit your translation files—once a month or after each major release.
- If you use a CMS, consider using a plugin that optimizes translation key storage.
Troubleshooting
Error persists after removing keys. Clear your cache or rebuild your translation bundle. Sometimes the old count is cached. Also, check if the limit is on the total number of characters, not just keys—some systems count characters.
App breaks after merging keys. You likely merged keys that had different values. Revert the merge and instead use parameters to differentiate context.
Some languages show missing translations. After removing keys, ensure you removed them from all language files, not just the default one. If a key is missing in a non-default language, the app might fall back to the default or show the key itself.
Limit is still exceeded after cleanup. You may have more keys than you think. Re-count and look for auto-generated keys (e.g., from a plugin). Consider splitting into multiple translation files or using a different storage method.
You can't find the limit setting. Search your code for a constant like MAX_TRANSLATION_KEYS or maxKeys. In some platforms, it's in the admin panel under “Settings” or “Plan Limits.”
Frequently Asked Questions
What exactly is a translation key?
A translation key is a unique identifier used to look up a translated string. For example, header.title might map to “Welcome” in English and “Bienvenue” in French.
Why is there a limit on translation keys?
Limits are often imposed by translation management platforms to control server load and storage. They also encourage developers to keep translation files manageable.
Can I increase the limit without paying?
Sometimes. If you are self-hosting, you can modify the source code. For SaaS platforms, you usually need to upgrade your plan. Check your provider's documentation.
How do I know which keys are unused?
Use a static analysis tool or write a script that scans your code for all calls to your translation function (e.g., t() or __()) and compares them against your key list.
Will merging keys affect my translations?
Only if the keys have different meanings. If you merge keys that are truly identical in meaning, you just need to update the references. If they differ, use parameters to handle variations.
What if I still need more keys after cleaning up?
Consider restructuring your app to load translations on demand, or use a different storage backend like a database instead of flat files. If you're on a platform, contact support to discuss your needs.