Download the PHP package modera/translations-bundle without Composer

On this page you can find all versions of the php package modera/translations-bundle. 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 translations-bundle

ModeraTranslationsBundle

Bundle defines architecture and provides utilities which make process of translating your web-site to many languages an easier process.

Bundle's has been developed to simplify a process of localizing your bundles, to achieve that it does several things:

Installation

Step 1: Download the Bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

This bundle should be automatically enabled by Flex. In case you don't use Flex, you'll need to manually enable the bundle by adding the following line in the config/bundles.php file of your project:

Step3: Updated database

Documentation

Bundles ships two command line tasks:

modera:translations:import

This task as you are already probably guessed is used to extract tokens from your files to database. In order for this task to understand what files it should extract tokens from you need to register so called 'translations handlers'. At the moment of writing we had support for two type of handlers: "twig templates" and "php files".

To inform the task that a bundle's twig templates ( Resources/views directory ) must be scanned you need to use a service definition akin to the following:

If you also want to have your bundle's PHP files to be scanned then can use something similar to this:

Now if you run modera:translations:import tasks then both twig templates and all *.php files located inside the YourBundleName will be scanned, tokens extracted and finally added to database.

When it comes to working with localization in twig templates there's nothing new, you just use trans twig filters provided by Symfony, but situation gets more interesting when you need to localize your php code though. Natively, you can use translator service, but before you can use it you need to inject it to your services and even when you injected it Symfony still won't be able to detect and extract tokens from it, to solve this problem we have created an implementation of a standard Symfony ExtractorInterface - Modera\TranslationsBundle\TokenExtraction\PhpClassTokenExtractor. This class is able to statically analyze your PHP files and extract tokens from it, to make code analysis more bullet-proof we decided to introduce a helper that you should use to translate your messages and designate them as translations tokens - Modera\FoundationBundle\Translation\T. This class provides static method - trans, its purpose and method signatures are mirrored to standard Symfony's Symfony\Contracts\Translation\TranslatorInterface. You can use this method to translate your messages without having to import translator service to your services beforehand. You may be wondering how these methods work - essentially, when ModeraTranslationsBundle is bootstrapped by Symfony, the bundle will inject translator service to T class and latter will use it to translate your messages. Probably you already have another question - how do I test my services in unit tests if they rely on a service coming from dependency injection container ? The answer is simple - you test your classes the same way as you always did, T is smart enough and when it is executed without having access to automatically injected translator service it will just act as proxy class without actually translating your messages. Here a few examples how you can use T service:

Now when you run modera:translations:import command these tokens will be extracted:

modera:translations:compile

Once translation tokens have been extracted to database, translated you probably will want to compile them back to physical files so Symfony translation mechanism could detect them and use when translating messages. For this to happen you need to run modera:translations:compile tasks. During execution this task will compile all translation tokens from database to root Resources directory of your application.

Licensing

This bundle is under the MIT license. See the complete license in the bundle: Resources/meta/LICENSE


All versions of translations-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
doctrine/orm Version ^2.5
doctrine/doctrine-bundle Version ^2.0
symfony/framework-bundle Version ^5.4|^6.0
modera/languages-bundle Version ^5.0
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 modera/translations-bundle contains the following files

Loading the files please wait ....