How to manage shared translation keys across projects

Kinga Pomykała
Kinga Pomykała
Last updated: March 10, 20255 min read
How to manage shared translation keys across projects

When working on multiple projects, you'll often find yourself reusing the same translation keys across different applications. Without a structured approach, this can lead to inconsistencies, duplication, and increased maintenance efforts. But don't worry—there are effective ways to manage this!

In this article, we'll explore how to handle shared translation keys in SimpleLocalize, ensuring consistency, organization, and easy updates.

What are shared translation keys?

Imagine you have two projects in SimpleLocalize: one for your software's webpage and another for the software itself. Both projects share common translation keys like button.submit, button.login, button.cancel, home, and support.

When you update button.submit in one project, you want that translation to automatically apply to the other. This eliminates duplication, ensures uniformity, and reduces manual work.

Now, let's explore the best strategies for managing shared translation keys efficiently using SimpleLocalize.

Method 1: Using a dedicated project for shared keys

One of the best ways to maintain consistency is by creating a Shared Key Repository, a centralized project that houses all common translations. This acts as a single source of truth, ensuring seamless updates across multiple projects.

Shared Key Repository

Advantages of this approach:

  • You manage all shared keys in one place.
  • You can export shared keys as a separate file and use them in multiple projects.
  • You avoid duplicating the same keys across different projects.
  • Updating translations in one place automatically ensures consistency in all connected projects.

How to implement this:

  1. Create a separate project in SimpleLocalize and name it something like “Common Keys".
  2. Add all shared translation keys to this project.
  3. Download translations from the common keys, join them with project-specific translations, and use them in your projects. You can use Translation Hosting and the SimpleLocalize CLI to automate this process.
  4. Regularly update translations in this repository so that all projects using these shared keys stay synchronized.

With this approach, you can also create a separate project for your glossary. By managing glossary terms and translations in one place, you can use translation memory to check and reuse correct translations in other projects.

Method 2: Managing all keys in one project

Another strategy is storing all translations in a single project, differentiating between shared and project-specific keys using namespaces, tags, customers, or structured translation keys.

Namespaces

Namespaces are a powerful way to organize translation keys within one project. They help you group keys by their purpose or origin, making it easier to manage and update translations. Depending on your needs, you can use namespaces to categorize keys by project, platform, or feature.

For managing different projects and shared keys in one SimpleLocalize project, you can:

  • Store shared keys without a namespace.
  • Assign project-specific keys under namespaces like app, web.
Namespace-based organization

However, if you are already using namespaces for other purposes, this approach may not be suitable. In such cases, consider using tags, customers, or structured translation keys to differentiate shared and project-specific keys.

Learn more about namespaces in SimpleLocalize.

Tags

Tags are another way to categorize translation keys within one project. You can use tags to group keys by their purpose, platform, or feature, making it easier to manage and update translations.

Tags can be assigned regardless of the key's namespace, allowing you to customize translations for different projects without affecting others.

Tag-based organization

Learn more about tags in SimpleLocalize.

Customers

Using customer context is not an obvious approach as it bases on a different concept. Let's say, 90% of your translation keys are shared across all projects, and only 10% are project-specific.

In this case, you can create a customer context for each project and adjust translations per project without affecting others.

Customer-based organization

Using this method, you update base translations for shared keys in one place and customize translations for each project using customer context.

Learn more about customer context in SimpleLocalize.

Translation keys

Another way to manage shared and project-specific keys is to use translation keys. You can create a naming convention for translation keys to differentiate between shared and project-specific keys.

For example, you can use commmon.button.submit, common.button.login, common.button.cancel for shared keys and app.button.submit, web.button.login, mobile.button.cancel for project-specific keys.

This method is suitable for projects where you need to maintain a single project for all translations while customizing translations for different platforms or features. It's a flexible approach that allows you to organize and update translations based on your needs.

Translation key-based organization

Learn more about translation keys in SimpleLocalize.

Separate projects with duplicated keys

This default approach involves creating separate projects for each application or platform, with duplicated translation keys across projects. While this method is straightforward, it can lead to inconsistencies and maintenance challenges.

At the same time, this approach gives you more flexibility to customize translations for each project without affecting others. It's suitable for projects with few shared keys or where you need to maintain separate translations for different platforms.

Translation memory

Translation Memory is an additional feature that can help ensure consistency across different projects and translation approaches. It stores all translations and allows you to reuse them without manually copying text.

How Translation Memory helps:

  • Suggests previously used translations for the same or similar keys.
  • Ensures translation consistency across different projects.
  • Saves time and reduces translation costs.

This feature supports both approaches mentioned earlier, helping to maintain a unified and error-free translation experience.

Learn more about Translation Memory in SimpleLocalize.

Conclusion

Each method has its advantages and is suitable for different scenarios. Choose the one that best fits your needs and project requirements. By managing shared translation keys effectively, you can ensure consistency, reduce duplication, and simplify translation updates across multiple projects.

SimpleLocalize offers various customization options to help you organize and maintain translations efficiently. Whether you prefer a separate project for shared keys, a single project with namespaces, tags, customers, or translation keys, or separate projects with duplicated keys, you can find the right approach for your projects.

Kinga Pomykała
Kinga Pomykała
Content creator of SimpleLocalize