PHP Class lajax\translatemanager\Module
Initialisation example:
Simple example:
~~~
'modules' => [
'translatemanager' => [
'class' => 'lajax\translatemanager\Module',
],
],
~~~
Complex example:
~~~
'modules' => [
'translatemanager' => [
'class' => 'lajax\translatemanager\Module',
'root' => '@app', // The root directory of the project scan.
'layout' => 'language', // Name of the used layout. If using own layout use 'null'.
'allowedIPs' => ['127.0.0.1'], // IP addresses from which the translation interface is accessible.
'roles' => ['@'], // For setting access levels to the translating interface.
'tmpDir' => '@runtime', // Writable directory for the client-side temporary language files.
IMPORTANT: must be identical for all applications (the AssetsManager serves the JavaScript files containing language elements from this directory).
'phpTranslators' => ['::t'], // list of the php function for translating messages.
'jsTranslators' => ['lajax.t'], // list of the js function for translating messages.
'patterns' => ['*.js', '*.php'],// list of file extensions that contain language elements.
'ignoredCategories' => ['yii'], // these categories won’t be included in the language database.
'ignoredItems' => ['config'], // these files will not be processed.
'languageTable' => 'language', // Name of the database table storing the languages.
'scanTimeLimit' => null, // increase to prevent "Maximum execution time" errors, if null the default max_execution_time will be used
'searchEmptyCommand' => '!', // the search string to enter in the 'Translation' search field to find not yet translated items, set to null to disable this feature
'defaultExportStatus' => 1, // the default selection of languages to export, set to 0 to select all languages by default
'defaultExportFormat' => 'json',// the default format for export, can be 'json' or 'xml'
'tables' => [ // Properties of individual tables
[
'connection' => 'db', // connection identifier
'table' => '{{%language}}', // table name
'columns' => ['name', 'name_ascii'], //names of multilingual fields
'category' => 'database-table-name', // the category is the database table name
]
]
],
],
~~~
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: http://www.yiiframework.com/doc-2.0/guide-security-authorization.html
examples:
PhpManager:
~~~
'components' => [
'authManager' => [
'class' => 'yii\rbac\PhpManager',
],
],
~~~
DbManager:
~~~
'components' => [
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
],
~~~
Exibir arquivo
Open project: lajax/yii2-translate-manager
Class Usage Examples
Public Properties
Property |
Type |
Description |
|
$allowedIPs |
|
the list of IPs that are allowed to access this module. |
|
$connection |
|
The default db connection |
|
$controllerNamespace |
|
|
|
$defaultExportFormat |
|
The default export format (yii\web\Response::FORMAT_JSON or yii\web\Response::FORMAT_XML). |
|
$defaultExportStatus |
|
The minimum status for a language to be selected by default in the export list. |
|
$defaultRoute |
|
|
|
$googleApiKey |
|
google API Key for using with google translate service (v2). Default is false - google translate will not be available. |
|
$ignoredCategories |
|
list of the categories being ignored. |
|
$ignoredItems |
|
directories/files being ignored. |
|
$jsTranslators |
|
List of the JavaScript function for translating messages. |
|
$languageTable |
|
The database table storing the languages. |
|
$layout |
|
name of the used layout. If you want to use the site default layout set value null. |
|
$patternArray |
|
PHP Regular expression to match arrays containing language elements to translate. |
|
$patternArrayRecursive |
|
PHP Regular expression to detect langualge elements within arrays. |
|
$patternArrayTranslator |
|
PHP Regular expression to match arrays containing language elements to translate. |
|
$patternJs |
|
Regular expression to detect JavaScript lajax.t functions. |
|
$patternPhp |
|
Regular expression to match PHP Yii::t functions. |
|
$patterns |
|
list of file extensions that contain language elements.
Only files with these extensions will be processed. |
|
$phpTranslators |
|
List of the PHP function for translating messages. |
|
$roles |
|
the list of rights that are allowed to access this module.
If you modify, you also need to enable authManager.
http://www.yiiframework.com/doc-2.0/guide-security-authorization.html |
|
$root |
|
The root directory or directories of the scanning. The path can be an alias or
a full path.
It is possible to define one root directory as string. In this case the scanRootParentDirectory will be used
when determining the actual directory to scan.
Multiple root directories can be declared in an array. In this case all items must point to the exact directory,
as scanRootParentDirectory **will be omitted**. |
|
$scanRootParentDirectory |
|
Whether scan the defined root parent directory, or the folder itself. This option is used only,
when the root option contains a single directory as string (e.g. 'root' => '@app').
IMPORTANT: Changing this from true to false could cause loss of translated items, as
optimize action removes the missing items.
If the configured root is @app:
- true means for advanced apps, that the scan runs on the parent directory, which is the root for the entire project.
This is the desired behavior.
- true means for basic apps, that the scan runs also on the parent directory, which is outside of the project folder
(as @app is equals to the project root). This is not desired behavior, it is preferred to change this option
to false. |
|
$scanTimeLimit |
|
The max_execution_time used when scanning, when set to null the default max_execution_time will not be modified. |
|
$scanners |
|
Scanners can be overriden here. If not set original set of scanners will be used from Scanner |
|
$searchEmptyCommand |
|
The search string to find empty translations. |
|
$subDir |
|
name of the subdirectory which contains the language elements. |
|
$tables |
|
~~~
$tables = [
[
'connection' => 'db', // connection identifier.
'table' => '{{%language}}', // name of the database table to scan.
'columns' => ['name', 'name_ascii'] // fields to check.
],
[
'connection' => 'db', // connection identifier.
'table' => '{{%post}}', // name of the database table to scan.
'columns' => ['title', 'description', 'content']// fields to check.
],
];
~~~ |
|
$tmpDir |
|
writeable directory used for keeping the generated javascript files. |
|
Public Methods
Method Details
beforeAction()
public method
checkAccess()
public method
getLanguageItemsDirPath()
public method
Property Details
$allowedIPs public_oe property
the list of IPs that are allowed to access this module.
$connection public_oe property
The default db connection
$controllerNamespace public_oe property
public $controllerNamespace |
$defaultExportStatus public_oe property
The minimum status for a language to be selected by default in the export list.
public $defaultExportStatus |
$defaultRoute public_oe property
$googleApiKey public_oe property
google API Key for using with google translate service (v2). Default is false - google translate will not be available.
$ignoredCategories public_oe property
list of the categories being ignored.
public $ignoredCategories |
$ignoredItems public_oe property
directories/files being ignored.
$jsTranslators public_oe property
List of the JavaScript function for translating messages.
$languageTable public_oe property
The database table storing the languages.
$layout public_oe property
name of the used layout. If you want to use the site default layout set value null.
$patternArray public_oe property
PHP Regular expression to match arrays containing language elements to translate.
$patternArrayRecursive public_oe property
PHP Regular expression to detect langualge elements within arrays.
public $patternArrayRecursive |
$patternArrayTranslator public_oe property
PHP Regular expression to match arrays containing language elements to translate.
public $patternArrayTranslator |
$patternJs public_oe property
Regular expression to detect JavaScript lajax.t functions.
$patternPhp public_oe property
Regular expression to match PHP Yii::t functions.
$patterns public_oe property
list of file extensions that contain language elements.
Only files with these extensions will be processed.
$phpTranslators public_oe property
List of the PHP function for translating messages.
$roles public_oe property
the list of rights that are allowed to access this module.
If you modify, you also need to enable authManager.
http://www.yiiframework.com/doc-2.0/guide-security-authorization.html
The root directory or directories of the scanning. The path can be an alias or
a full path.
It is possible to define one root directory as string. In this case the scanRootParentDirectory will be used
when determining the actual directory to scan.
Multiple root directories can be declared in an array. In this case all items must point to the exact directory,
as scanRootParentDirectory **will be omitted**.
$scanRootParentDirectory public_oe property
Whether scan the defined root parent directory, or the folder itself. This option is used only,
when the root option contains a single directory as string (e.g. 'root' => '@app').
IMPORTANT: Changing this from true to false could cause loss of translated items, as
optimize action removes the missing items.
If the configured root is @app:
- true means for advanced apps, that the scan runs on the parent directory, which is the root for the entire project.
This is the desired behavior.
- true means for basic apps, that the scan runs also on the parent directory, which is outside of the project folder
(as @app is equals to the project root). This is not desired behavior, it is preferred to change this option
to false.
public $scanRootParentDirectory |
$scanTimeLimit public_oe property
The max_execution_time used when scanning, when set to null the default max_execution_time will not be modified.
$scanners public_oe property
Scanners can be overriden here. If not set original set of scanners will be used from Scanner
$searchEmptyCommand public_oe property
The search string to find empty translations.
public $searchEmptyCommand |
$subDir public_oe property
name of the subdirectory which contains the language elements.
$tables public_oe property
~~~
$tables = [
[
'connection' => 'db', // connection identifier.
'table' => '{{%language}}', // name of the database table to scan.
'columns' => ['name', 'name_ascii'] // fields to check.
],
[
'connection' => 'db', // connection identifier.
'table' => '{{%post}}', // name of the database table to scan.
'columns' => ['title', 'description', 'content']// fields to check.
],
];
~~~
$tmpDir public_oe property
writeable directory used for keeping the generated javascript files.