Shopify Development

Shopify Multi-Language Mastery: Solving the 3,400 Key Limit in Locale Files

Hey there, fellow Shopify store owners and developers! At Shopping Cart Mover, we often help merchants navigate the complexities of e-commerce, from seamless migrations to optimizing their online presence. One crucial aspect of reaching a global audience is offering your store in multiple languages. Shopify provides robust tools for this, but like any powerful platform, it has its nuances and occasional technical limits.

Recently, a valuable discussion in the Shopify Community shed light on a specific, yet often perplexing, issue: the 3,400 key limit in theme locale files. If you're running a multi-language store, especially one that has evolved over time, understanding and managing this limit is crucial for a smooth customer experience.

Comparing Shopify locale JSON files in a code editor
Comparing Shopify locale JSON files in a code editor

Decoding the Locale File Limit: What Happened to ivoivo?

Our community member, @ivoivo, encountered this exact challenge. They were diligently managing their store’s translations, specifically with their Latvian locale file, lv.json. While their default English file, en.default.json, was a lean 502 keys, their lv.json had ballooned to around 3,400 translatable value keys. The perplexing part? Everything looked fine syntactically – no missing commas, broken brackets, or invalid JSON. Yet, Shopify support correctly identified the lv.json file hitting a hidden limit.

This scenario is more common than you might think, particularly for stores that have undergone several theme updates, experimented with various translation apps, or manually added translations over the years. Old, unused translation keys can accumulate, turning your locale files into digital hoards that eventually hit a ceiling.

Why Do Locale Files Get Bloated?

Shopify themes, apps, and even custom code rely on locale files (JSON files like en.default.json, fr.json, es.json, etc.) to store all the translatable text strings displayed on your storefront. Each piece of text – a product title, a button label, a checkout message – corresponds to a unique "key" in these files.

Bloated locale files typically result from:

  • Theme Updates: When you update your theme or switch to a new one, old translation keys from previous versions might linger in your custom locale files.
  • App Installations/Uninstallations: Many Shopify apps add their own translation keys. If an app is uninstalled, its keys might not always be automatically removed from your theme's locale files.
  • Manual Customizations: Developers or store owners might add custom keys for specific content, and these might not be cleaned up if the content is removed.
  • Third-Party Translation Services: Some services might generate comprehensive translation files that include keys for every possible string, even those not actively used by your current theme.

The 3,400 key limit isn't about the file size or character count; it's about the sheer number of distinct keys Shopify's system needs to process for a single locale file. Exceeding this can lead to unexpected errors, translation failures, or even prevent theme updates.

The Community's Consensus: Synchronize Your Keys

The solution, as highlighted by @SectionKit in the thread, is quite straightforward: your translated locale files should ideally mirror the keys found in your default locale file.

As @SectionKit put it, "Your lv.json has way more keys than it needs. Since your en.default.json only has 502 keys, your lv.json should match that. Any extra keys can be safely removed." This is the critical insight. Shopify's system expects your translated files to provide translations for the keys present in your default theme. Keys that exist only in a translated file are essentially redundant and contribute to the key count without serving a current purpose.

It's also important to note that "Splitting the file is not supported by Shopify," as @SectionKit confirmed. This means you can't break a large locale file into smaller ones to bypass the limit. The only viable approach is to streamline the existing file.

Step-by-Step Guide to Fixing Bloated Locale Files

Ready to clean up your locale files and ensure your multi-language store runs smoothly? Here’s how:

1. Identify Your Default Locale File

This is usually en.default.json (for English) or whichever language you've set as your primary store language. This file serves as your reference point for all active translation keys.

2. Identify the Problematic Locale File(s)

Based on Shopify support's feedback or your own observations, pinpoint which translated .json files are exceeding the limit (e.g., lv.json, fr.json).

3. Access Your Theme Code

From your Shopify admin, go to Online Store > Themes. Find your current theme, click Actions > Edit code. Navigate to the Locales folder.

4. Compare and Cleanse the Files

This is the most critical step. You need to compare the problematic locale file (e.g., lv.json) against your default locale file (e.g., en.default.json) and remove any keys from the problematic file that do not exist in the default.

  • For Developers (Recommended): Use a code editor like VS Code (as suggested by @Maximus3) with a JSON comparison extension. Tools like "JSON Compare" or "Diff Tool" extensions can visually highlight differences, making it easy to identify and remove extra keys. You can also use online JSON diff tools, but be cautious with sensitive data.
  • Manual Method (for very small differences): If you only have a few extra keys, you might be able to manually go through both files. However, for 3,400 keys, this is highly impractical.
  • Programmatic Approach: For advanced users, writing a small script (e.g., in Python or Node.js) to parse both JSON files, compare their keys, and generate a cleaned version of the translated file is the most efficient method.

// Example of a key structure in a JSON locale file
{
  "general": {
    "add_to_cart": "Add to cart",
    "read_more": "Read more"
  },
  "products": {
    "title": "Products",
    "price": "Price"
  }
}

Ensure that when you remove keys, you maintain valid JSON syntax (correct commas, brackets, etc.).

5. Test and Deploy

After making changes, save the updated locale file. It's always a good practice to test your store thoroughly, especially in the affected language, to ensure all necessary translations are still present and functioning correctly. If you're working on a live store, consider duplicating your theme and making changes there first.

Preventative Measures and Best Practices

To avoid hitting this limit again, consider these best practices:

  • Regular Audits: Periodically review your locale files, especially after major theme updates or app installations/uninstallations.
  • Mindful App Usage: When installing translation apps, understand how they manage locale files. Some apps might offer better cleanup options than others.
  • Clean Theme Development: If you're developing a custom theme or making significant customizations, ensure you only add translation keys that are actively used.
  • Version Control: Use Git or a similar version control system for your theme code. This allows you to track changes to locale files and easily revert if issues arise.

By keeping your locale files lean and synchronized, you ensure your Shopify store remains performant, easy to manage, and delivers a flawless multi-language experience to your global customer base. For merchants looking to expand their reach or even start a new Shopify store, paying attention to these details can make all the difference.

At Shopping Cart Mover, we believe a well-optimized store is a successful store. Managing your locale files effectively is just one piece of the puzzle in building a robust and scalable e-commerce presence.

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases