Download the PHP package odan/twig-translation without Composer

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

Twig Translation Extension

A Twig Translation Extension.

Latest Version on Packagist Build Status Code Coverage Scrutinizer Code Quality Total Downloads

Please read this first!

The symfony/twig-bridge also provides a Twig 3 TranslationExtension to translate messages with the trans filter. For this reason the odan/twig-translation component is just redundant and will be deprecated in the near future. I strongly recommend you to use the symfony/twig-bridge TranslationExtension instead.

Here you can find an installation guide:

Requirements

Installation

Registering the extension

This example uses the symfony/translation component:

Register the Twig Extension:

Slim 4 integration

To install the symfony/translation component, run:

Add settings:

Add a new container definition:

Create a global translation function

This step is optional, but recommend if you want to translate messages directly in PHP.

Create the file src/Utility/translate.php and copy / paste this content:

Register the composer autoloader in composer.json:

Run: composer update

Usage

Translate a text:

Translate a text with a placeholder:

Output (depends on the language):

Translate a text with multiple placeholders:

Output (depends on the language):

Create a plural translation:

Example 1:

Example 2:

Create a complex plural translation:

Parsing with Poedit

The workflow

  1. Parse all twig files (php bin/parse-twig.php)
  2. Start Poedit and open the .po file
  3. Click the Update button to parse all PHP and Twig cache files
  4. Translate the text and save the file.

Poedit Setup

Parsing Twig files

You need to iterate and compile all your Twig templates. The compilation step generates the PHP cache files that can be parsed from Poedit. This script is only an example and must be adapted to your individual environment.

Twig settings:

File: bin/parse-twig.php

To run this script just enter: php bin/parse-twig.php

Similar libraries

The symfony/twig-bridge provides TranslationExtension for Twig 3+.

Read more

License


All versions of twig-translation with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
twig/twig Version ^3.1
symfony/translation-contracts Version ^2
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 odan/twig-translation contains the following files

Loading the files please wait ....