Using our little helper library called T15S Registry, you can then tell WordPress that translations for your project should be loaded from TranslationsPress.
Note: T15S Registry requires PHP 7.1 or higher.
Copy the library’s code to your project. Also, on a multisite install it’s recommended to use it in a must-use plugin.
As more and more plugin developers use T15S library to deliver translations updates to their products, there is a conflict risk with another plugin/theme including a different version of the library class than you are packaging with your plugin/theme.
You should rename this class and init function name and parameters to something unique to your plugin/theme, so that it avoids conflicts.
Change any references of:
$type: either plugin or theme.
$slug: must match the theme/plugin directory slug.
$api_url: the URL to the TranslationsPress project translation API.
Note: It’s important that the slug matches the folder name of the plugin or theme.
Ideally you call
add_project() in a function hooked to init, e.g. like this: