Download the PHP package tonchik-tm/yii2-translate-manager without Composer
On this page you can find all versions of the php package tonchik-tm/yii2-translate-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-translate-manager
Yii2 - Translate Manager
Online Translations
Introduction
This module provides a simple translating interface for the multilingual elements of your project. It can auto-detect new language elements (project scan). Duplications are filtered out automatically during project scanning. Unused language elements can be removed from the database with a single click (database optimisation) and translations can be imported and exported. It is possible to translate client side messages too (those stored in JavaScript files) as the project scan collects language elements to be translated from JavaScript files as well.
It also allows you to translate text on the client side (on the live webpage) without having to log in to the translating interface. (frontendTranslation).
On the server side it can handle database or one-dimensional/multidimensional array elements and Yii::t functions. You can exclude files, folders or categories to prevent them from being translated.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Migration
Run the following command in Terminal for database migration:
Linux/Unix:
Windows:
Config
A simple exmple of turning on Yii database multilingual.
Turning on the TranslateManager Module:
Simple example:
A more complex example including database table with multilingual support is below:
IMPORTANT: If you want to modify the value of roles (in other words to start using user roles) you need to enable authManager in the common config.
Using of authManager.
examples:
PhpManager:
DbManager:
Front end translation:
Usage
Register client scripts
To translate static messages in JavaScript files it is necessary to register the files.
To register your scripts, call the following method in each action:
A simple example for calling the above method at each page load:
ToggleTranslate button
Simple example for displaying a button to switch to front end translation mode. (The button will only appear for users who have the necessary privileges for translating!)
A more complex example for displaying the button:
Placing multilingual elements in the source code.
JavaScript:
PHP methods:
PHP functions for front end translation:
PHP arrays:
PHP Database:
URLs
URLs for the translating tool:
Example implementation of the Yii2 menu into your own menu.
Console commands
Register the command
Use it with the Yii CLI