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',
],
],
~~~
파일 보기
프로젝트 열기: lajax/yii2-translate-manager
1 사용 예제들
공개 프로퍼티들
프로퍼티 |
타입 |
설명 |
|
$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. |
|
공개 메소드들
메소드 상세
getLanguageItemsDirPath()
공개 메소드
프로퍼티 상세
the list of IPs that are allowed to access this module.
The default db connection
$controllerNamespace 공개적으로 프로퍼티
public $controllerNamespace |
$defaultExportStatus 공개적으로 프로퍼티
The minimum status for a language to be selected by default in the export list.
public $defaultExportStatus |
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.
public $ignoredCategories |
directories/files being ignored.
$jsTranslators 공개적으로 프로퍼티
List of the JavaScript function for translating messages.
$languageTable 공개적으로 프로퍼티
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.
$patternArrayRecursive 공개적으로 프로퍼티
PHP Regular expression to detect langualge elements within arrays.
public $patternArrayRecursive |
$patternArrayTranslator 공개적으로 프로퍼티
PHP Regular expression to match arrays containing language elements to translate.
public $patternArrayTranslator |
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.
$phpTranslators 공개적으로 프로퍼티
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 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.
public $scanRootParentDirectory |
$scanTimeLimit 공개적으로 프로퍼티
The max_execution_time used when scanning, when set to null the default max_execution_time will not be modified.
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.
public $searchEmptyCommand |
name of the subdirectory which contains the language elements.
~~~
$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.
],
];
~~~
writeable directory used for keeping the generated javascript files.