There is no license information available for the latest version (v1.0) of this package.

Installs: 1 115

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 0

Open Issues: 0


v1.0 2020-01-22 19:56 UTC

This package is auto-updated.

Last update: 2023-03-11 21:01:40 UTC


Babelfish is a lightweight string registry package. It allows you to use string aliases in your codebase instead of using the actual strings. This makes it much easier to find and edit the strings themselves.

In addition to that, if you're using Blade templates, you don't have to worry about gettext / poedit / wpml not being able to parse your templates properly.


composer require codelight/babelfish ^1.0


In your functions.php:


load_theme_textdomain('your_text_domain', get_stylesheet_directory());

// Register aliases and corresponding strings:
    'button.payment' => __('Complete payment',     'your_text_domain'),
    'button.cta'     => __('Buy now for only %s!', 'your_text_domain'),

However, I recommend creating a separate file, e.g. translations.php which contains everything related to translations.

To get the translations:

  <?php echo _t('button.payment'); // Complete payment! ?>
  <?php echo _t('button.cta', '$420.69'); // Buy now for only $420.69!  ?>

As you can see from the above example, the translation function also supports sprintf-style variable substitution. You can use any number of variables in your _t() function.