Download the PHP package inpsyde/translation-cache without Composer

On this page you can find all versions of the php package inpsyde/translation-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package translation-cache

Inpsyde Translation Cache

Improves site performance by caching translation files using WordPress object cache.


Description

'Inpsyde Translation Cache' provides caching of the translation .mo files using WP Object Cache mechanism.

Performance benefit of the plugin can be seen when using persistent cache plugin because, by default, WordPress object cache does not 'survive' the single request and translation files are already cached on a per-request basis in WP.

For this reason the plugin, by default, does nothing when there's no persistent caching plugin installed.


MU plugin self-installation

Considering that many plugins have their language files, to be allowed to cache plugins translations, 'Inpsyde Translation Cache' has to run as MU plugin.

For this reason, 'Inpsyde Translation Cache' copies its main file to the MU plugin folder on installation, so it can work as MU plugin.

The 'regular' plugin stays active though, but doing nothing, or better, it listed for deactivation to delete the MU plugin copy.

In fact, when 'regular' plugin is deactivated, the MU plugin copy is deleted (unless it was modified).

Please note that on some configurations this 'self-installation' routine may not work, e.g. if MU plugins folder is not writable.

In those cases 'Inpsyde Translation Cache' will continue to work as a regular plugin, but it will not be able to cache translation files loaded before 'plugins_loaded' hook is fired. Moreover, an admin notice is also shown to suggest users to manually copy main plugin file to MU plugins folder to improve performance.


Cache invalidation

'Inpsyde Translation Cache' stores all the text domains:

it means that when a new version of those is installed, the cache need to cleared.

Automatic invalidation

For invalidation of WordPress core translations the plugin relies on WordPress version: if that change all cached core translations are invalidated.

For plugin and themes, things are less straightforward.

'Inpsyde Translation Cache' uses 'switch_theme' hook to invalidate cache of both the 'old' and the 'new' theme.

It also uses 'activated_plugin' and 'deactivated_plugin' to invalidate cache for plugins.

However, to invalidate cache of themes and plugins 'Inpsyde Translation Cache' needs to know the text domain they use.

For that scope, 'Inpsyde Translation Cache' uses 'TextDomain' file header of plugin and themes.

Considering that 'TextDomain' file header is not mandatory, it is possible that some plugins or themes that don't provide that header (even if they should).

Manual invalidation

In those cases it is possible to invalidate the cache 'manually' by calling Inpsyde\MoCache::flush_cache() method.

For example, let's assume there's a plugin that loads a text domain like this:

and let's assume this plugin has not in plugin headers something like:

'Inpsyde Translation Cache' will not be able to flush cache for that plugin automatically when activated and deactivated.

However, 'manually' invalidating cache for that plugin would be just a matter of:

Of course, when it is possible to edit the plugin to include the Text Domain plugin header, it is surely better, because 'Inpsyde Translation Cache' will be able to invalidate the cache for plugin translations automatically.

For themes the workflow is very similar, just use 'switch_theme' hook to intercept theme change.

Invalidation by version

There's another way to invalidate cached translations.

'Inpsyde Translation Cache' builds an unique key for the combination of text domain and .mo file path.

This unique key is built using an 'hash' of:

It means that using mocache_cache_version filter it is possible to invalidate all the stored keys for a given text domain.

For example, assuming same plugin as above we could do:

So we use the 'Version' plugin header to invalidate the cache whenever the version change.

Compared to the 'manual' approach above, this approach has the benefit to do not explicitly call 'Inpsyde Translation Cache' objects, so there's no need to check for class existence, in fact, if 'Inpsyde Translation Cache' is not installed or not activated, then the code does nothing with no effect.

But it also has two flaws:

So, again, the suggestion is to use Text Domain header whenever possible, maybe suggesting to maintainers of third party plugins and themes to add it when not present.


Available hooks

'Inpsyde Translation Cache' provides some hooks for customization. Most of them will only work properly from a MU plugin, especially if 'Inpsyde Translation Cache' is running as MU plugin.

Available action hooks:

Available filter hooks:


Installation

'Inpsyde Translation Cache' is available via Composer with package name inpsyde/mo-cache, but it does not require Composer to be installed or used.

The 'classical' installation method (download -> put in plugins folder -> activate) works as well.


Requirements


License

This repository is a free software, and is released under the terms of the GNU General Public License version 2 or (at your option) any later version. See LICENSE for complete license.

'Inpsyde Translation Cache' incorporates work covered by the following copyright and permission notices:

The team at Inpsyde is engineering the Web since 2006.


All versions of translation-cache with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package inpsyde/translation-cache contains the following files

Loading the files please wait ....