Class lajax\translatemanager\Module
Inheritance | lajax\translatemanager\Module » yii\base\Module |
---|---|
Available since version | 1.0 |
This is the main module class for the 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
'categoryPrefix' => 'lx-'
]
]
],
],
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',
],
],
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$allowedIPs | array | The list of IPs that are allowed to access this module. | lajax\translatemanager\Module |
$controllerNamespace | lajax\translatemanager\Module | ||
$defaultExportFormat | string | The default export format (yii\web\Response::FORMAT_JSON or yii\web\Response::FORMAT_XML). | lajax\translatemanager\Module |
$defaultExportStatus | integer | The minimum status for a language to be selected by default in the export list. | lajax\translatemanager\Module |
$defaultRoute | lajax\translatemanager\Module | ||
$ignoredCategories | array | List of the categories being ignored. | lajax\translatemanager\Module |
$ignoredItems | array | Directories/files being ignored. | lajax\translatemanager\Module |
$jsTranslators | array | List of the JavaScript function for translating messages. | lajax\translatemanager\Module |
$languageTable | string | The database table storing the languages. | lajax\translatemanager\Module |
$layout | string | Name of the used layout. | lajax\translatemanager\Module |
$patternArray | string | PHP Regular expression to match arrays containing language elements to translate. | lajax\translatemanager\Module |
$patternArrayRecursive | string | PHP Regular expression to detect langualge elements within arrays. | lajax\translatemanager\Module |
$patternArrayTranslator | string | PHP Regular expression to match arrays containing language elements to translate. | lajax\translatemanager\Module |
$patternJs | string | Regular expression to detect JavaScript lajax. | lajax\translatemanager\Module |
$patternPhp | string | Regular expression to match PHP Yii::t functions. | lajax\translatemanager\Module |
$patterns | array | List of file extensions that contain language elements. | lajax\translatemanager\Module |
$phpTranslators | array | List of the PHP function for translating messages. | lajax\translatemanager\Module |
$roles | array | The list of rights that are allowed to access this module. | lajax\translatemanager\Module |
$root | string | The root directory of the scanning. | lajax\translatemanager\Module |
$scanTimeLimit | integer | The max_execution_time used when scanning, when set to null the default max_execution_time will not be modified. | lajax\translatemanager\Module |
$searchEmptyCommand | string | The search string to find empty translations. | lajax\translatemanager\Module |
$subDir | string | Name of the subdirectory which contains the language elements. | lajax\translatemanager\Module |
$tables | array | Identifiers for the database tables containing language elements. | lajax\translatemanager\Module |
$tmpDir | string | Writeable directory used for keeping the generated javascript files. | lajax\translatemanager\Module |
Public Methods
Method | Description | Defined By |
---|---|---|
beforeAction() | lajax\translatemanager\Module | |
checkAccess() | lajax\translatemanager\Module | |
getLanguageItemsDirPath() | lajax\translatemanager\Module |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
SESSION_KEY_ENABLE_TRANSLATE | 'frontendTranslation_EnableTranslate' | Session key for storing front end translating privileges. | lajax\translatemanager\Module |
Property Details
The list of IPs that are allowed to access this module.
The default export format (yii\web\Response::FORMAT_JSON or yii\web\Response::FORMAT_XML).
The minimum status for a language to be selected by default in the export list.
List of the categories being ignored.
Directories/files being ignored.
List of the JavaScript function for translating messages.
The database table storing the languages.
Name of the used layout. If you want to use the site default layout set value null.
PHP Regular expression to match arrays containing language elements to translate.
PHP Regular expression to detect langualge elements within arrays.
PHP Regular expression to match arrays containing language elements to translate.
Regular expression to detect JavaScript lajax.t functions.
Regular expression to match PHP Yii::t functions.
List of file extensions that contain language elements. Only files with these extensions will be processed.
List of the PHP function for translating messages.
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 of the scanning.
The max_execution_time used when scanning, when set to null the default max_execution_time will not be modified.
The search string to find empty translations.
Name of the subdirectory which contains the language elements.
Identifiers for the database tables containing language elements.
Writeable directory used for keeping the generated javascript files.
Method Details
public void beforeAction ( $action ) | ||
$action |
public boolean checkAccess ( ) | ||
return | boolean | Whether the module can be accessed by the current user |
---|
public string getLanguageItemsDirPath ( ) | ||
return | string | The full path of the directory containing the generated JavaScript files. |
---|