Text Domains Across Multiple Plugins & Themes

You don’t. Translations are part of each item’s commit history, they should be kept as separate as the PHP code. In terms of performance, you don’t win much with a combined text domain. Actually, you could lose performance, because if you need that one translation array almost everywhere, you cannot load it selectively anymore or destroy it when you don’t need it.

One way to do what you want, is a separate plugin, maybe named “Client Name translations”, duplicate all strings in that and let the translators translate this file only. Prepare for sync hell. 🙂

Or you move all strings to a separate file with a single array …

<?php 
return array(
    'name1' => __( 'Name one', 'your_text_domain' ),
    'name2' => __( 'Name two', 'your_text_domain' )
);

… and require_once that file in all other sub-projects (or write a wrapper plugin for it). Then you access the strings by their keys.

But I would try to keep separate commit histories for all projects. Once you want to reuse one of them you have to rewrite everything anyway.

Leave a Comment

tech