Download the PHP package pollora/helper-overrider without Composer

On this page you can find all versions of the php package pollora/helper-overrider. 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 helper-overrider

Pollora Helper Overrider

Replaces WordPress's __() with one that serves both the Laravel and the WordPress translation catalogues, so a Pollora application can write either style and get the right answer.

How the override happens

WordPress declares __() unguarded in wp-includes/l10n.php, so it cannot simply be redefined. The Pollora framework patches WordPress core to rename it to __wp() (patches/wordpress-core.patch, applied through cweagans/composer-patches), which frees the name for this package's src/helpers.php, loaded via Composer's autoload.files.

This package must stay dependency-free.

laravel/framework also declares __(), behind the same function_exists() guard, and Composer emits autoload.files in dependency order. The package only wins the race while nothing sorts it after laravel/framework. Adding an illuminate/* entry to require fails nothing loudly — __() silently becomes Laravel's, and every WordPress catalogue stops resolving. The Laravel classes are reached through PSR-4 at call time instead, long after the autoloader is up, and guarded by class_exists(). tests/Unit/OverrideOrderTest.php is the alarm for this.

How a call is routed

The two translators do not overlap, and the second argument is what tells them apart.

Call Routed to Why
__('Some string') Laravel, then WordPress default No intent expressed. The only ambiguous case, and the only one where both are consulted.
__('Some string', 'my-plugin') WordPress, my-plugin domain A text domain is an explicit WordPress call. Laravel is never consulted, so an unrelated key of the same name cannot shadow a plugin's catalogue.
__('Shipping :brand', ['brand' => 'X']) Laravel, then WordPress default — placeholders filled either way Named replacements are a Laravel idiom. WordPress has no named placeholders: a msgid uses %s, substituted by sprintf() at the call site.

There is no key-prefix escape hatch to force one side over the other. A prefix like wordpress. would be invisible to gettext extraction tools (wp i18n make-pot, Poedit) — they read the literal __() argument, so a translator would translate a msgid the runtime never actually looks up once the prefix is stripped. If you need WordPress specifically, pass its text domain; if you need Laravel specifically, pass replacements (even an unused empty one won't do — see the ambiguous row above).

For the third row, if the key is absent from the Laravel catalogue the line is taken from WordPress — which returns the key verbatim when it knows nothing about it — and the named placeholders are filled in regardless. That is what keeps __('Shipping :brand', ['brand' => 'Test']) from rendering as Shipping :brand in a locale you have not translated.

Locale resolution

The WordPress locale (fr_FR) is tried first, then its base language (fr). Laravel's JSON lookup — the one __() uses — matches the locale exactly and has no language fallback of its own, so without this a project shipping lang/fr.json would never be consulted on a fr_FR site. An existing lang/fr_FR.json still wins.

Scope

Only __() is overridden. The rest of the WordPress family (_e(), _x(), _n(), esc_html__() …) does not route through __() in core — those call translate(), translate_with_gettext_context() and translate_plural() directly — so each would need its own core patch. Two of them have no faithful mapping anyway:

Known limitation

Per-class handlers registered through Lang::stringable() apply on the Laravel path but not on the WordPress-fallback path, where such objects fall back to __toString(). The fallback line comes from a gettext catalogue rather than the Laravel one and must keep working with no application booted, so it substitutes placeholders through ReplacementApplier rather than through the translator. ReplacementApplierParityTest diffs that class against a real Illuminate\Translation\Translator to keep the two in step.

Requirements

Development

License

MIT — see LICENSE.


All versions of helper-overrider with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
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 pollora/helper-overrider contains the following files

Loading the files please wait ...