Download the PHP package timber/wp-i18n-twig without Composer

On this page you can find all versions of the php package timber/wp-i18n-twig. 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 wp-i18n-twig

wp-i18n-twig

tests

Parsing WordPress translations in Twig/Timber templates has always been quirky and not very convenient. Especially since WordPress started grabbing translations from multiple sources (theme stylesheet, {block,theme}.json, block editor JS, PHP files) and now also outputing in multiple formats (po, php).

WP-CLI being the recommended way to create/update POT files, timber/wp-i18n-twig provides (almost native) Twig translation extraction by overriding the default wp i18n make-pot.

Install

Because WP-CLI default commands are not meant to be overridden, there are two working ways to install timber/wp-i18n-twig:

Global

If you want to use it with a global installed wp (/usr/local/bin/wp or similar), you have to install it as a WP-CLI package:

Local

You can also install the package at the project level using composer and run WP-CLI from the local vendor/bin/wp:

Usage

Usage is the same than wp i18n make-pot command.

--debug flag is handy if you want to check the templates that have been parsed (and watch for parsing errors):

Please refer to the wp i18n command documentation for more detailed information.

To match wp i18n make-pot behavior, a --skip-twig flag has been added in case skipping Twig files extraction is needed.

Translations

timber/wp-i18n-twig handles the same translations functions and feature scope wp i18n does.

It does also support translators comments, at an evil cost.

Adding translators comments in your Twig templates works like it would in PHP, place it on the same line or the line before the translation string:

Custom tags

When working with Twig, you may require popular Twig libraries that register custom tags (such as {% dump %}, {% cache %}, etc.). timber/wp-i18n-twig will automatically load the token parsers for the following tags:

[!IMPORTANT] For the token parsers to be loaded, you must use the local version of timber/wp-i18n-twig (vendor/bin/wp).

Limitations

To make this package work in any Twig environment, templates are not compiled to PHP but only parsed. This main benefit is that it's (almost) configuration agnostic (custom filters, functions, template location).

However, since Twig is highly configurable, there are still some (minor) limitations.


All versions of wp-i18n-twig with dependencies

PHP Build Version
Package Version
Requires twig/twig Version ^3.0
wp-cli/i18n-command Version ^2.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 timber/wp-i18n-twig contains the following files

Loading the files please wait ....