PHP Класс 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', ], ], ~~~
С версии: 1.0
Автор: Lajos Molnár ([email protected])
Наследование: extends yii\base\Module
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
beforeAction ( $action )
checkAccess ( ) : boolean
getLanguageItemsDirPath ( ) : string

Описание методов

beforeAction() публичный Метод

public beforeAction ( $action )

checkAccess() публичный Метод

public checkAccess ( ) : boolean
Результат boolean whether the module can be accessed by the current user

getLanguageItemsDirPath() публичный Метод

public getLanguageItemsDirPath ( ) : string
Результат string The full path of the directory containing the generated JavaScript files.

Описание свойств

$allowedIPs публичное свойство

the list of IPs that are allowed to access this module.
public $allowedIPs

$connection публичное свойство

The default db connection
public $connection

$controllerNamespace публичное свойство

public $controllerNamespace

$defaultExportFormat публичное свойство

The default export format (yii\web\Response::FORMAT_JSON or yii\web\Response::FORMAT_XML).
public $defaultExportFormat

$defaultExportStatus публичное свойство

The minimum status for a language to be selected by default in the export list.
public $defaultExportStatus

$defaultRoute публичное свойство

public $defaultRoute

$googleApiKey публичное свойство

google API Key for using with google translate service (v2). Default is false - google translate will not be available.
public $googleApiKey

$ignoredCategories публичное свойство

list of the categories being ignored.
public $ignoredCategories

$ignoredItems публичное свойство

directories/files being ignored.
public $ignoredItems

$jsTranslators публичное свойство

List of the JavaScript function for translating messages.
public $jsTranslators

$languageTable публичное свойство

The database table storing the languages.
public $languageTable

$layout публичное свойство

name of the used layout. If you want to use the site default layout set value null.
public $layout

$patternArray публичное свойство

PHP Regular expression to match arrays containing language elements to translate.
Устаревший: since version 1.2.7
public $patternArray

$patternArrayRecursive публичное свойство

PHP Regular expression to detect langualge elements within arrays.
Устаревший: since version 1.2.7
public $patternArrayRecursive

$patternArrayTranslator публичное свойство

PHP Regular expression to match arrays containing language elements to translate.
public $patternArrayTranslator

$patternJs публичное свойство

Regular expression to detect JavaScript lajax.t functions.
Устаревший: since version 1.2.7
public $patternJs

$patternPhp публичное свойство

Regular expression to match PHP Yii::t functions.
Устаревший: since version 1.2.7
public $patternPhp

$patterns публичное свойство

list of file extensions that contain language elements. Only files with these extensions will be processed.
public $patterns

$phpTranslators публичное свойство

List of the PHP function for translating messages.
public $phpTranslators

$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
public $roles

$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**.
public $root

$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.
public $scanRootParentDirectory

$scanTimeLimit публичное свойство

The max_execution_time used when scanning, when set to null the default max_execution_time will not be modified.
public $scanTimeLimit

$scanners публичное свойство

Scanners can be overriden here. If not set original set of scanners will be used from Scanner
public $scanners

$searchEmptyCommand публичное свойство

The search string to find empty translations.
public $searchEmptyCommand

$subDir публичное свойство

name of the subdirectory which contains the language elements.
public $subDir

$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. ], ]; ~~~
public $tables

$tmpDir публичное свойство

writeable directory used for keeping the generated javascript files.
public $tmpDir