Giter Site home page Giter Site logo

lajax / yii2-translate-manager Goto Github PK

View Code? Open in Web Editor NEW
228.0 22.0 88.0 2.3 MB

Translation Manager

License: MIT License

PHP 86.54% JavaScript 7.82% CSS 2.04% TSQL 3.60%
yii2 yii2-extension yii2-widgets translate multilingual translation-management php translation-interface

yii2-translate-manager's Introduction

Yii2 - Translate Manager

Latest Version on Packagist Software License Total Downloads

Translation management extension for Yii 2

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.

Contributing

Please read and follow the instructions in the Contributing guide.

Installation

Via Composer

composer require lajax/yii2-translate-manager

Migration

Run the following command in Terminal for database migration:

yii migrate/up --migrationPath=@vendor/lajax/yii2-translate-manager/migrations

Or use the namespaced migration (requires at least Yii 2.0.10):

// Add namespace to console config:
'controllerMap' => [
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationNamespaces' => [
            'lajax\translatemanager\migrations\namespaced',
        ],
    ],
],

Then run:

yii migrate/up

Config

A simple exmple of turning on Yii database multilingual.

'language' => 'en-US',
'components' => [
    'i18n' => [
        'translations' => [
            '*' => [
                'class' => 'yii\i18n\DbMessageSource',
                'db' => 'db',
                'sourceLanguage' => 'xx-XX', // Developer language
                'sourceMessageTable' => '{{%language_source}}',
                'messageTable' => '{{%language_translate}}',
                'cachingDuration' => 86400,
                'enableCaching' => true,
            ],
        ],
    ],
],

Turning on the TranslateManager Module:

Simple example:

'modules' => [
    'translatemanager' => [
        'class' => 'lajax\translatemanager\Module',
    ],
],

A more complex example including database table with multilingual support is below:

'modules' => [
    'translatemanager' => [
        'class' => 'lajax\translatemanager\Module',
        'root' => '@app',               // The root directory of the project scan.
        'scanRootParentDirectory' => true, // Whether scan the defined `root` parent directory, or the folder itself.
                                           // IMPORTANT: for detailed instructions read the chapter about root configuration.
        '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.
        'onlyCategories' => ['yii'],    // only these categories will be included in the language database (cannot be used together with "ignoredCategories").
        'ignoredItems' => ['config'],   // these files will not be processed.
        '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
            ]
        ],
        'scanners' => [ // define this if you need to override default scanners (below)
            '\lajax\translatemanager\services\scanners\ScannerPhpFunction',
            '\lajax\translatemanager\services\scanners\ScannerPhpArray',
            '\lajax\translatemanager\services\scanners\ScannerJavaScriptFunction',
            '\lajax\translatemanager\services\scanners\ScannerDatabase',
        ],
    ],
],

Configuring the scan root

The root path can be an alias or a full path (e.g. @app or /webroot/site/).

The file scanner will scan the configured folders for translatable elements. The following two options determine the scan root directory: root, and scanRootParentDirectory. These options are defaults to values that works with the Yii 2 advanced project template. If you are using basic template, you have to modify these settings.

The root options tells which is the root folder for project scan. It can contain a single directory (string), or multiple directories (in an array).

The scanRootParentDirectory is used only if a single root directory is specified in a string.

IMPORTANT: Changing these options could cause loss of translated items, as optimize action removes the missing items. So be sure to double check your configuration!

a) Single root directory:

It is possible to define one root directory as string in the root option. In this case the scanRootParentDirectory will be used when determining the actual directory to scan.

If scanRootParentDirectory is set to true (which is the default value), the scan will run on the parent directory. This is desired behavior on advanced template, because the @app is the root for the current app, which is a subfolder inside the project (so the entire root of the project is the parent directory of @app).

For basic template the @app is also the root for the entire project. Because of this with the default value of scanRootParentDirectory, the scan runs outside the project folder. This is not desired behavior, and changing the value to false solves this.

IMPORTANT: Changing the scanRootParentDirectory from true to false could cause loss of translated items, as the root will be a different directory.

For example:

root value scanRootParentDirectory value Scanned directory
/webroot/site/frontend true /webroot/site
/webroot/site/frontend false /webroot/site/frontend

b) Multiple root directories:

Multiple root directories can be defined in an array. In this case all items must point to the exact directory, as scanRootParentDirectory will be omitted.

For example:

'root' => [
    '@frontend',
    '@vendor',
    '/some/external/folder',
],

Using of authManager

Examples:

PhpManager:

'components' => [
    'authManager' => [
        'class' => 'yii\rbac\PhpManager',
    ],
    // ...
],

DbManager:

'components' => [
    'authManager' => [
        'class' => 'yii\rbac\DbManager',
    ],
    // ...
],

Front end translation:

'bootstrap' => ['translatemanager'],
'components' => [
    'translatemanager' => [
        'class' => 'lajax\translatemanager\Component'
    ]
]

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:

\lajax\translatemanager\helpers\Language::registerAssets();

A simple example for calling the above method at each page load:

namespace common\controllers;

use lajax\translatemanager\helpers\Language;

// IMPORTANT: all Controllers must originate from this Controller!
class Controller extends \yii\web\Controller {

    public function init() {
        Language::registerAssets();
        parent::init();
    }
}

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!)

\lajax\translatemanager\widgets\ToggleTranslate::widget();

A more complex example for displaying the button:

\lajax\translatemanager\widgets\ToggleTranslate::widget([
 'position' => \lajax\translatemanager\widgets\ToggleTranslate::POSITION_TOP_RIGHT,
 'template' => '<a href="javascript:void(0);" id="toggle-translate" class="{position}" data-language="{language}" data-url="{url}"><i></i> {text}</a><div id="translate-manager-div"></div>',
 'frontendTranslationAsset' => 'lajax\translatemanager\bundles\FrontendTranslationAsset',
 'frontendTranslationPluginAsset' => 'lajax\translatemanager\bundles\FrontendTranslationPluginAsset',
]);

Placing multilingual elements in the source code.

JavaScript:

lajax.t('Apple');
lajax.t('Hello {name}!', {name:'World'});
lajax.t("Don't be so upset.");

PHP methods:

Yii::t('category', 'Apple');
Yii::t('category', 'Hello {name}!', ['name' => 'World']);
Yii::t('category', "Don't be so upset.");

PHP functions for front end translation:

use lajax\translatemanager\helpers\Language as Lx;

Lx::t('category', 'Apple');
Lx::t('category', 'Hello {name}!', ['name' => 'World']);
Lx::t('category', "Don't be so upset.");

IMPORTANT: The lajax\translatemanager\helpers\Language::t() (Lx::t()) function currently does not support the translation of HTMLattributes

PHP arrays:

/**
 * @translate
 */
private $_STATUSES = [
    self::STATUS_INACTIVE => 'Inactive',
    self::STATUS_ACTIVE => 'Active',
    self::STATUS_DELETED => 'Deleted'
];

/**
 * Returning the 'status' array on the site's own language.
 * return array
 */
public function getStatuses() {
    return \lajax\translatemanager\helpers\Language::a($this->_STATUSES);
}

/**
 * @translate
 */
private $_GENDERS = ['Male', 'Female'];

/**
 * Returning the 'genders' array in German
 * return array
 */
public function getGenders() {
    return \lajax\translatemanager\helpers\Language::a($this->_GENDERS, 'de-DE');
}

PHP Database:

  • With new attributes:
namespace common\models;

use lajax\translatemanager\helpers\Language;

/**
 * This is the model class for table "category".
 *
 * @property string $category_id
 * @property string $name
 * @property string $description
 */
class Category extends \yii\db\ActiveRecord {

    // afterFind & beforeSave:

    /**
     * @var Returning the 'name' attribute on the site's own language.
     */
    public $name_t;

    /**
     * @var Returning the 'description' attribute on the site's own language.
     */
    public $description_t;

    /* ... */

    public function afterFind() {
        $this->name_t = Language::d($this->name);
        $this->description_t = Language::d($this->descrioption);

        // or If the category is the database table name.
        // $this->name_t = Language::t(static::tableName(), $this->name);
        // $this->description_t = Language::t(static::tableName(), $this->description);
        parent::afterFind();
    }

    public function beforeSave($insert) {
        if (parent::beforeSave($insert)) {
            Language::saveMessage($this->name);
            Language::saveMessage($this->description);

            // or If the category is the database table name.
            // Language::saveMessage($this->name, static::tableName());
            // Language::saveMessage($this->description, static::tableName());

            return true;
        }

        return false;
    }

    // or GETTERS:

    /**
     * @return string Returning the 'name' attribute on the site's own language.
     */
    public function getName($params = [], $language = null) {
        return Language::d($this->name, $params, $language);

        // or If the category is the database table name.
        // return Language::t(static::tableName(), $this->name, $params, $language);
    }

    /**
     * @return string Returning the 'description' attribute on the site's own language.
     */
    public function getDescription($params = [], $language = null) {
        return Language::d($this->description, $params, $language);

        // or If the category is the database table name.
        // return Language::t(static::tableName(), $this->description, $params, $language);
    }
}
  • With behavior (since 1.5.3):

    This behavior does the following:

    • Replaces the specified attributes with translations after the model is loaded.
    • Saves the attribute values as:
      1. Source messages, if the current language is the source language.
      2. Translations, if the current language is different from the source language. This way the value stored in database is not overwritten with the translation.

    Note: If the model should be saved as translation, but the source message does not exist yet in the database then the message is saved as the source message whether the current language is the source language or not. To avoid this scan the database for existing messages when using the behavior first, and only save new records when the current language is the source language.

namespace common\models;

/**
 * This is the model class for table "category".
 *
 * @property string $category_id
 * @property string $name
 * @property string $description
 */
class Category extends \yii\db\ActiveRecord {

    // TranslateBehavior

    public function behaviors()
    {
        return [
            [
                'class' => \lajax\translatemanager\behaviors\TranslateBehavior::className(),
                'translateAttributes' => ['name', 'description'],
            ],

            // or If the category is the database table name.
            // [
            //     'class' => \lajax\translatemanager\behaviors\TranslateBehavior::className(),
            //     'translateAttributes' => ['name', 'description'],
            //     'category' => static::tableName(),
            // ],
        ];
    }

}

URLs

URLs for the translating tool:

/translatemanager/language/list         // List of languages and modifying their status
/translatemanager/language/create       // Create languages
/translatemanager/language/scan         // Scan the project for new multilingual elements
/translatemanager/language/optimizer    // Optimise the database

Example implementation of the Yii2 menu into your own menu.

$menuItems = [
    ['label' => Yii::t('language', 'Language'), 'items' => [
            ['label' => Yii::t('language', 'List of languages'), 'url' => ['/translatemanager/language/list']],
            ['label' => Yii::t('language', 'Create'), 'url' => ['/translatemanager/language/create']],
        ]
    ],
    ['label' => Yii::t('language', 'Scan'), 'url' => ['/translatemanager/language/scan']],
    ['label' => Yii::t('language', 'Optimize'), 'url' => ['/translatemanager/language/optimizer']],
    ['label' => Yii::t('language', 'Im-/Export'), 'items' => [
        ['label' => Yii::t('language', 'Import'), 'url' => ['/translatemanager/language/import']],
        ['label' => Yii::t('language', 'Export'), 'url' => ['/translatemanager/language/export']],
    ]
];

Console commands

Register the command

'controllerMap' => [
    'translate' => \lajax\translatemanager\commands\TranslatemanagerController::className()
],

Use it with the Yii CLI

./yii translate/scan
./yii translate/optimize

Known issues

  • Scanner is scanning parent root directory #12.

    You can overwrite this behavior with the scanRootParentDirectory option. (See Config section for details.)

  • Frontend translation of strings in hidden tags corrupts HTML. #45

Coding style

The project uses the PSR-2 coding standard.

Coding style issues can be fixed using the following command:

composer cs-fix

You can check the code, without affecting it:

composer cs-fix-dry-run

Change log

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

Screenshots

List of languages

translate-manager-0 2-screen-1

Scanning project

translate-manager-0 2-screen-2

Optimise database

translate-manager-0 2-screen-3

Translate on the admin interface

translate-manager-0 2-screen-4

Front end in translating mode

translate-manager-0 2-screen-6

Translate on the front end

translate-manager-0 2-screen-7

Links

yii2-translate-manager's People

Contributors

bjornhij avatar cebe avatar ilgiz-badamshin avatar lajax avatar maksymsemenykhin avatar maxxer avatar moltam avatar nbogol avatar rhertogh avatar richweber avatar schmunk42 avatar sluchznak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-translate-manager's Issues

Scanner is scanning parent root directory (!?)

Hi,

I have my application set up with the configuration file at this location:
/home/mywww/myapp/frontend/config/main.php
In this file, I set up your module and the value for 'root' is dirname(dirname(__DIR__))
which maps to/home/mywww/myapp
When I run a scan, I get error messages for not being able to open folders under /home/mywww (outside the 'myapp' folder). Why is that?
I also tried to put the path manually like this:
'root'=>'/home/mywww/myapp/'
and I get the same result.
If I put it like:
'root'=>'/home/mywww/myapp/frontend/', it seems to search 'myapp', but for some reason, it doesn't find any instances of Y::t('app','') in my project. And I have this in every file!
What am I doing wrong?

Here is my full config for the module:

    'translatemanager' => [
        'class' => 'lajax\translatemanager\Module',
        //'root' => dirname(dirname(__DIR__)),               // The root directory of the project scan.
        'root' => '/home/mywww/myapp/',               // The root directory of the project scan.
        'layout' => null,//'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' => ['theCreator','translator'],               // 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.
    ],

Any ideas?

Separate TranslateBehavior example

The new TranslateBehavior example could be separated in the readme. I think it would be more clear if the old and new examples were separated.

Declaration \services\scanners\ScannerFile::extractMessages() incompatible

With latest Yii2 2.0.4-dev this error occurs on scan and optimize page:

PHP Strict Warning – yii\base\ErrorException
Declaration of lajax\translatemanager\services\scanners\ScannerFile::extractMessages() should be compatible with yii\console\controllers\MessageController::extractMessages($fileName, $translator, $ignoreCategories = Array)

To fix it, just alter lajax\translatemanager\services\scanners\ScannerFile in line 123:

old:
protected function extractMessages($fileName, $options) {

new:
protected function extractMessages($fileName, $options, $ignoreCategories = []) {

problem in migration (advanced app template)

Hi,
i've installed the translate-manager but i've a problem with migration command:
yii migrate/up --migrationPath=@vendor/lajax/yii2-translate-manager/migrations
i get " unknown property request::cookies "
deleting language-picker configurations solved the problem

Menu Translation

Hi,
I'm using yii2 advanced template. but menu translation is not working.
I'm using Yii::t('language', 'Home'); or Lx::t('language', 'Home') in frontend view.

"Home" action error Not Found (#404) page not found

backend/config/main.php
`<?php
$params = array_merge(
require(DIR . '/../../common/config/params.php'),
require(DIR . '/../../common/config/params-local.php'),
require(DIR . '/params.php'),
require(DIR . '/params-local.php')
);

return [
'id' => 'app-backend',
'basePath' => dirname(DIR),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'homeUrl' => '/project2/administrator',
'components' => [
'request' => [
'baseUrl' => '/project2/administrator',
],

    'user' => [
        'identityClass' => 'common\models\User',    
        'enableAutoLogin' => true,                  
        'identityCookie' => [                       
            'name' => '_backendIdentity',           
            'httpOnly' => true,                     
            'path' => '/',
            ],      
    ],
    'session' => [                                  
        'name' => 'BACKENDSESSID',                  
        'cookieParams' => [                         
            'httpOnly' => true,
            'path' => '/',              

        ],
    ],  

    'assetManager' => [
        'bundles' => [
            'dmstr\web\AdminLteAsset' => [
                'skin' => 'skin-red-light',
            ],
        ],
    ],      

    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
        ],
    ],
    'errorHandler' => [
        'errorAction' => 'site/error',
    ],
],
'params' => $params,

];
`

common/config/main.php
`<?php
return [
//Default
'vendorPath' => dirname(dirname(DIR)) . '/vendor',
'name'=>'PROJECT2',
'bootstrap' => [
/* 'translate', */
'languagepicker',
'translatemanager'
],
'language' => 'id-ID',
'sourceLanguage' => 'en-US',
'components' => [
//Default
'cache' => [
'class' => 'yii\caching\FileCache',
],

/* 'i18n' => [
'class' => 'yii\i18n\I18N',
'translations' => [
'*' => [
'class' => 'conquer\i18n\MessageSource',
'translator' => [
'class'=>'conquer\i18n\translators\GoogleTranslator',
'apiKey' => 'AIzaSyCl9B5SNTjJdtvuqDUkMF9qIbPj6EeRcms',
// 'class'=>'conquer\i18n\translators\YandexTranslator',
// 'apiKey' => 'yandex form',
],
],
],
], */

    //  I18n  lajax
    'i18n' => [
        'translations' => [
            '*' => [
                'class' => 'yii\i18n\DbMessageSource',
                'db' => 'db',
                'sourceLanguage' => 'en-US', // Developer language
                'sourceMessageTable' => '{{%language_source}}',
                'messageTable' => '{{%language_translate}}',
                'forceTranslation' => true,
                'cachingDuration' => 86400,
                'enableCaching' => false,
            ],
            'app' => [
                'class' => 'yii\i18n\DbMessageSource',
                'db' => 'db',
                'sourceLanguage' => 'en-US', // Developer language
                'sourceMessageTable' => '{{%language_source}}',
                'messageTable' => '{{%language_translate}}',
                'forceTranslation' => true,
                'cachingDuration' => 86400,
                'enableCaching' => false,
            ],
            'yii' => [
                'class' => 'yii\i18n\DbMessageSource',
                'db' => 'db',
                'sourceLanguage' => 'en-US', // Developer language
                'sourceMessageTable' => '{{%language_source}}',
                'messageTable' => '{{%language_translate}}',
                'forceTranslation' => true,
                'cachingDuration' => 86400,
                'enableCaching' => false,
            ],
        ],
    ],


    // lajax language picker manual pilih
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',        // List of available languages (icons and text)
        'languages' => ['id-ID' => 'Bahasa Indonesia']
    ],

    // lajax language picker translatemanager

/* 'languagepicker' => [
'class' => 'lajax\languagepicker\Component',
'languages' => function () { // List of available languages (icons and text)
return \lajax\translatemanager\models\Language::getLanguageNames(true);
},
'cookieName' => 'language', // Name of the cookie.
//'cookieDomain' => '//localhost/pustaka', // Domain of the cookie.
'expireDays' => 64, // The expiration time of the cookie is 64 days.
'callback' => function() {
if (!\Yii::$app->user->isGuest) {
$user = \Yii::$app->user->identity;
$user->language = \Yii::$app->language;
$user->save();
}
}
], */

    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
            // your rules go here
            ],
            // ...
    ],

],

/* 'modules' => [
'translate' => 'conquer\i18n\Module', // Untuk I18n

],
     */

// Untuk I18n  lajax
'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' => ['*'],          // IP addresses from which the translation interface is accessible.
        'roles' => ['@'],               // For setting access levels to the translating interface.
        'tmpDir' => '@frontend/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.
        '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
            ],
        ]
    ],
],

];
if make comment for this 'enablePrettyUrl' => true,
'showScriptName' => false,`

'Home' action run normal else it goes to frontend even the url show in the browser "//localhost/project2/administrator" till I change to be "//localhost/project2/backend/web" it back normal again.
What is going on?

ToggleTranslate button

Hi!
Can you help me, please?
I following instructions on the description to the this component. Translate manager work fine. Its awesome extension. Thank you so much.
But, I can`t understand how to use toggle translate button on my app.

The letter attached my config...

lajax.tar.gz

Dinamic translate from database

The default language is set to Italian. When choosing another language everything works great except for those elements which are stored in the database.

In the database I store the products. Through the settings added to the translation table products with fields : name and description.

Yu can see it
https://voilasrl.com/product/index
And choose another lang

'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
],
[
'connection' => 'db', // connection identifier
'table' => '{{%product}}', // table name
'columns' => ['name', 'description'],// names of multilingual fields
],
[
'connection' => 'db', // connection identifier
'table' => '{{%product_category}}', // table name
'columns' => ['name', 'description'],// names of multilingual fields
],
[
'connection' => 'db', // connection identifier
'table' => '{{%tax}}', // table name
'columns' => ['name'],// names of multilingual fields
]
]

Explanation

The language is set as Italian, change the language to Spanish. Product name and description remains in Italian, everything else from the database is translated.

scan in wrong base path

it scans one level higher than defined. in configuration is defined as root "@app".
The path should i.e. /var/www/myapp but i get /var/www.
The Problem is line 204 in the following file:

/services/scanners/ScannerFile.php

wrong:
return dirname(Yii::getAlias($this->module->root));

correct:
return Yii::getAlias($this->module->root);

Yii::t dynamic translations

I have this lines:

$role = key(Yii::$app->authManager->getRolesByUser(Yii::$app->user->identity->id));
echo '<span>'.Yii::t('app',$role).'</span>';

Of course scan will not help me to define such messages and I am not able to translate them, there aren't in table. What's correct way should be? I think adding them manually is not good solution.

styling missing

I installed the extension, however I am not getting the css to render properly. When I checked I found that bootstrap.css is missing.

Can you please help?
Thank you

translatemanager

Cannot run yii translate/scan

I'm using Yii Advanced Template
I have configured translationmanager module in common/config/main.php and its visual interface works for backend like http://dev.yiia.com/backend/translatemanager/language/list
And frontend:
http://dev.yiia.com/frontend/translatemanager/language/list

  1. How can I scan both parts backend and frontend simultaneously? Now using visual interface I can do it separately for backend and frontend.
  2. I cannot run console command yii.bat translate/scan
    It returns Error: Unknown command "translate/scan"

Support connection prefix for database table names

I tried this migration, which basically worked.
But somewhere in the translate-manager the language table name was seem to be hardcoded, even if I reconfigured the property.

<?php

use yii\db\Schema;
use yii\db\Migration;

class m150626_231337_update_table_names extends Migration
{
    public function up()
    {
        $this->renameTable('language_translate', '{{%language_translate}}');
        $this->renameTable('language_source', '{{%language_source}}');
        $this->renameTable('language', '{{%language}}');
    }

    public function down()
    {
        $this->renameTable('{{%language_translate}}', 'language_translate');
        $this->renameTable('{{%language_source}}', 'language_source');
        $this->renameTable('{{%language}}', 'language');
    }
}

Would be nice if your module could adhere the connection prefix, since language is a very common name.

Optimaze

I am doing the translation attributes in the model through behavior. After the transfer, they entered into a database for translation. But when you start optimization removes them. Although their transfer is required.

How to exclude the removal by optimization?

public function behaviors() { return [ [ 'class' => TranslateBehavior::className(), 'translateAttributes' => ['name', 'description'], ], ]; }

Error

The translation module is needed only in the administrative part.

Button to switch the translation on the frontend does not work. The button appears, but no action happens when clicked.

Why should I link a module to the frontend to be translated via a button?

Ext. don't work on advansed template.

PHP Fatal Error – yii\base\ErrorException
Call to a member function checkAccess() on a non-object

https://s.mail.ru/5QXg/1naGZ22Zi

Auth manager is configured on common/config/main.conf

Toogle Translate doesn't work/

Configuration

common/config/main.php

http://pastebin.com/gUXXLMEB

frontend/config/main.php

http://pastebin.com/YMfR812c

backend/config/main.php
http://pastebin.com/whyGizrc

And controllers with init()

DialogAction does not return the requested translation.

As mentioned in #55 the DialogAction is not using the $_POST['language_id'] parameter when loads the translation model (due to removing the language parameter from LanguageSource::getLanguageTranslateByLanguage() ). As a consequence when saving, the wrong language is used, and translations will be overridden.

root can't be set as array

'translatemanager' => [
'class' => 'lajax\translatemanager\Module',
'root' => [
'@app/themes/seewroclaw',
'@app/modules',
],
],

causes

PHP Warning – yii\base\ErrorException

strncmp() expects parameter 1 to be string, array given

in /vendor/yiisoft/yii2/BaseYii.php

Optimize and Scan error only remotely

In my local server these two functions works with no problems.
Remotely, on the stage server (digital ocean virtual machine, backend on virtualhost with port 8081) i've this error:

schermata del 2016-04-07 17 41 02

Scanners have an issue due to eval usage

exception 'yii\base\ErrorException' with message 'syntax error, unexpected ')'' in /Users/philippfrenzel/Sites/ph-neighbordrop/vendor/lajax/yii2-translate-manager/services/scanners/ScannerFile.php(121) : eval()'d code:1
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

scan

After scan translatemanager want to delete category database. How exclude this category? Thanks.

Primary key for models

Hi.
I use postgresql views and primary key cannot be set in database metadata.
Is it possible to set primary key in Language,LanguageSource and LanguageTranslate models?

Tonda K.
Thanks.

Translations

Hello, how are you? I've implemented the plugin in my application but when the user isn't logged, the messages aren't translated, when the user is logged all works ok. Do you know the reason of this problem? Maybe the plugin has some configuration that block translations when the user isn't logged.

I would appreciate if you can help me with this issue! :)

LanguageSource::getLanguageTranslateByLanguage is not correct

In lajax/yii2-translate-manager/controllers/actions/DialogAction.php:30

$languageSource->getLanguageTranslateByLanguage(Yii::$app->request->post('language_id', ''))->one()

But in lajax/yii2-translate-manager/models/LanguageSource.php:113

\lajax\translatemanager\models\LanguageSource::getLanguageTranslateByLanguage()

without parameter 'language_id' and return first item.

You can improve the method so that it returns the desired translation?
Thank you

Root path problem

I found a bug in file: services/scanners/ScannerFile.php.

On line 203 there is a function named "_getRoot".

It looks like this:
private function _getRoot() {
return dirname(Yii::getAlias($this->module->root));
}

But it should be:
private function _getRoot() {
return Yii::getAlias($this->module->root);
}

You must not use the dirname function there because it cuts off the last folder from the path and starts scanning from 1 level higher folder. It scanned all my other projects aswell and the "dirname" function was the problem.

For example:
$dir = '/var/www/projects/myapp';
echo dirname($dir);
It will give you just '/var/www/projects' (last folder gets lost) so don't use dirname method here, Yii already provides valid path with Yii::getAlias.

unclear relation naming

The relations between the ActiveRecords have unclear names
E.g.

//LanguageTranslate.php

public function getId0() {
    return $this->hasOne(LanguageSource::className(), ['id' => 'id']);
}
public function getLanguage0() {
    return $this->hasOne(Language::className(), ['language_id' => 'language']);
}

I would expect:

public function getLanguageSource() {
    ...
}
public function getLanguage() {
   ...
}

Is this done with a specific reason?

Arabic language

For "ar-AR" language, textarea must have:
direction: rtl;

Translation not working

Hi, great extension (i see that from screenshot and administration tools) but i can't get it working.

In common config i have that:

'i18n' => [
            'translations' => [
                '*' => [
                    'class' => 'yii\i18n\DbMessageSource',
                    'db' => 'db',
                    'sourceLanguage' => 'en-US', // Developer language
                    'sourceMessageTable' => '{{%language_source}}',
                    'messageTable' => '{{%language_translate}}',
                    'cachingDuration' => 86400,
                    'enableCaching' => false,
                ],
            ],
        ],

and in custom frontend main config i've added module:

'translatemanager' => [
            'class' => 'lajax\translatemanager\Module',
        ],

translation manager is working great, i've scanned my project and have above 500 strings. So now i want to go to language 'en-US' and just for testing change some string with your editor. I'm saving changes, my translated string is visible in database table also it's still visible in your form. But on front i can't get it to work. I've tried to use this:

Html::a(Yii::t('dashboard', 'My Profile'), ['/settings'])

and that (with including on top of layout: use lajax\translatemanager\helpers\Language as Lx;):

Html::a(Lx::t('dashboard', 'My Profile'), ['/settings'])

but it's still showing my old default string - i can't overwrite it with your tools.

Could you tell me what am i doing wrong?

Thanks for your time and help.


also i have errors in log for some missing module translations like that:
The message file for category 'user' does not exist: /Library/WebServer/Documents/projectname/vendor/dektrium/yii2-user/messages/en/user.php

error since update

PHP Strict Warning – yii\base\ErrorException

Declaration of lajax\translatemanager\services\scanners\ScannerPhpFunction::run() should be compatible with yii\base\Controller::run($route, $params = Array)

a few questions

Hi,
i encontered a few problems while using of translate-manager
1 - "lajax\translatemanager\controllers\actions\DialigAction" return "LanguageTranslate" object in first available language instead $_POST['language_id']. The consequence of that is not correctly saved translation.
2 - the "Source language" default value does not match language used in "Source" column of gridview in first page load
3 - How about to use a category in lajax.t like Yii::t? Why you use fixed 'Javascript'?
4 - How about to use custom category for translateBehavior? Not only DATABASE and tableName. Can be improved in _getCategory method of ScannerDatabase class.
5 - also why is the dialog box is not done at the bootstrap
thanks

Move headers (h1) from views to layout

Hi,

what do you think about this? For example I use app layout for module, that already contain H1 tag, so resulted page has two headers...

If ok, I will provide PR for this.

Call to a member function checkAccess() on null in Frontend

/**
* Initialising front end translator.
*/
private function _initTranslation() {
$module = Yii::$app->getModule('translatemanager');

    if ($module->checkAccess() && $this->_checkRoles($module->roles)) {
        Yii::$app->session->set(Module::SESSION_KEY_ENABLE_TRANSLATE, true);
    }
}

what i am wrong in installation?

ReflectionException
Class lajax\translatemanager\Module does not exist

i have some problem with composer, i can not install, so i downloaded the extension from this reposity, imported sql tables and insert the folder in: vendor/lajax/yii2-translatemanager

Then i followed the steps in $config

the page is: url/translatemanager/language/scan

What i wrong?
thanks

Can't translate js in php file

Hi,

For some reason, the translate manager doesn't pick up the lajax.t() within a php file (specifically, the views of our webpage where we have some inline javascript).

Because this is a php file, it only scans for the ::t function. Even though I've tried adding the lajax.t() to the phpTranslators in the translatemanager config, the translatemanager still won't pick up on those javascript translate functions. Is there a way to get this working?

Not work with dmstr/yii2-adminlte-asset

I use "dmstr/yii2-adminlte-asset": "2.*".
put on top "
use lajax\translatemanager\helpers\Language;
\lajax\translatemanager\helpers\Language::registerAssets();
use lajax\translatemanager\helpers\Language as Lx;
"

Trying to put Lx::t('app','User Management') the error message "
Class 'Lx' not found ".

It's ok for original Yii2 Advance Framework.
How to solve this ?

Not saving translations nor language statuses

Hi,

I've managed to install and access the administration interface of the module (http://localhost/weep/frontend/web/index.php?r=translatemanager/language), but I am not able to save any translation because the request that is done after pressing the save button is the following:
Request URL:http://localhost/weep/frontend/web/save, which obviously doesn't exist!
Btw, this action works, http://localhost/weep/frontend/web/index.php?r=translatemanager/language/save, which I believe should be attached to the save button.

The same thing happens with the language status dropdown.

I am very new to Yii, so I apologise in advance if this is only the result of any miss configuration...

Not having access to the .js file containing the translations.

Good morning. Currently I'm using your translate manager in order to make the whole translation process a whole lot easier. It works beautifully but I have a single question. Just like your README said, I created a GlobalController so that every single one would extend this one. This Global is used to register the javascript files needed to support muli-language support on client-side.

class Controller extends \yii\web\Controller {

    /**
     * Method used to register JavaScript in order to translate them.
     */
    public function init() {
        Language::registerAssets();
        parent::init();
    }

}

My question is how am I supposed to register the javascript file containing the translations? When I use the above controller, the only javascript files registered are the following:

md5.js
lajax.js

I'm registering the one containing the translations like this:

this->registerJsFile('/yii2shop/frontend/TranslateJS/translate/' . \Yii::$app->language . '.js');

Am I doing something wrong or is this the way to register the file? In the README it says that the assetsmanager serves the Javascript files necessary files. The files mentioned are those two I mentioned above or is the one containing the translations included too?

Best Regards,
André Silva

Loosing DB data

Hello, I use your awesome extension.
I translate db message like this:

public $name_t;
public function afterFind() {
    $this->name_t = Language::d($this->name);
    $this->description_t = Language::d($this->descrioption);
    parent::afterFind();
}

public function beforeSave($insert) {
    if (parent::beforeSave($insert)) {
        Language::saveMessage($this->name);
        Language::saveMessage($this->description);

        return true;
    }

    return false;
}

But when I click on Scan link all database records will be found, and if I click on Optimize link (accidentally) script will remove my translations. But these mesages are still in use

translating text with html tags

The text should be checked for html tags and in this case turn on a wysiwyg editor (option to turn it on on plain text should be avail).
This is a must especially for long text which (probably) are translated by professional translator with no html coding capacity.

Frontend translation of strings in hidden tags corrupts HTML

Given this code in frontend:

<input id="sys_txt_keyword" class="txt-keyword" type="text" placeholder="<?=Lx::t("trusthau", "Search Actions")?>"/>

the resulting HTML is

<input id="sys_txt_keyword" class="txt-keyword" type="text" placeholder="<span class="language-item" data-category="trusthau" data-hash="5fdaa9de184eb548e41805c2be378e9d" data-language_id="it-IT" data-params="[]">Search Actions</span>"/>

which is invalid...

I don't know if you want to fix Lx::t or just add in the documentation not to use it in non viewable strings

Extend function for translate data from database

It will be good to have option for translation data from database to have different categories.

To have option like this:

[
                'connection' => 'db',   // connection identifier
                'table' => '{{%language}}',         // table name
                'columns' => ['name', 'name_ascii'] //names of multilingual fields,
                'category' => 'database-table-name', NEW
]

Error if extend Module


2015-09-30 16:02:01 [127.0.0.1][1][qkmdmv8gphir0r5op2ts870bs7][error][yii\base\ErrorException:8] exception 'yii\base\ErrorException' with message 'Trying to get property of non-object' in /Users/Yura/PhpstormProjects/realty-admin/vendor/lajax/yii2-translate-manager/models/searches/LanguageSourceSearch.php:87
Stack trace:
#0 /Users/Yura/PhpstormProjects/realty-admin/vendor/lajax/yii2-translate-manager/models/searches/LanguageSourceSearch.php(87): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/Users/Yura/Php...', 87, Array)
#1 [internal function]: lajax\translatemanager\models\searches\LanguageSourceSearch->lajax\translatemanager\models\searches\{closure}(Object(yii\db\ActiveQuery))
#2 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/ActiveQuery.php(494): call_user_func(Object(Closure), Object(yii\db\ActiveQuery))
#3 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/ActiveQuery.php(407): yii\db\ActiveQuery->joinWithRelations(Object(lajax\translatemanager\models\LanguageSource), Array, 'LEFT JOIN')
#4 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/ActiveQuery.php(145): yii\db\ActiveQuery->buildJoinWith()
#5 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/QueryBuilder.php(88): yii\db\ActiveQuery->prepare(Object(yii\db\pgsql\QueryBuilder))
#6 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/ActiveQuery.php(324): yii\db\QueryBuilder->build(Object(yii\db\ActiveQuery))
#7 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/Query.php(382): yii\db\ActiveQuery->createCommand(NULL)
#8 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/ActiveQuery.php(339): yii\db\Query->queryScalar('COUNT(*)', NULL)
#9 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/db/Query.php(296): yii\db\ActiveQuery->queryScalar('COUNT(*)', NULL)
#10 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/data/ActiveDataProvider.php(165): yii\db\Query->count('*', NULL)
#11 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/data/BaseDataProvider.php(147): yii\data\ActiveDataProvider->prepareTotalCount()
#12 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/data/ActiveDataProvider.php(105): yii\data\BaseDataProvider->getTotalCount()
#13 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/data/BaseDataProvider.php(79): yii\data\ActiveDataProvider->prepareModels()
#14 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/data/BaseDataProvider.php(92): yii\data\BaseDataProvider->prepare()
#15 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/data/BaseDataProvider.php(133): yii\data\BaseDataProvider->getModels()
#16 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/widgets/BaseListView.php(178): yii\data\BaseDataProvider->getCount()
#17 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/widgets/BaseListView.php(149): yii\widgets\BaseListView->renderSummary()
#18 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/grid/GridView.php(313): yii\widgets\BaseListView->renderSection('{summary}')
#19 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/widgets/BaseListView.php(126): yii\grid\GridView->renderSection('{summary}')
#20 [internal function]: yii\widgets\BaseListView->yii\widgets\{closure}(Array)
#21 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/widgets/BaseListView.php(129): preg_replace_callback('/{\\w+}/', Object(Closure), '{summary}\n{item...')
#22 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/grid/GridView.php(288): yii\widgets\BaseListView->run()
#23 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/Widget.php(98): yii\grid\GridView->run()
#24 /Users/Yura/PhpstormProjects/realty-admin/modules/translatemanager/views/language/translate.php(67): yii\base\Widget::widget(Array)
#25 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/View.php(325): require('/Users/Yura/Php...')
#26 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/View.php(247): yii\base\View->renderPhpFile('/Users/Yura/Php...', Array)
#27 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/View.php(149): yii\base\View->renderFile('/Users/Yura/Php...', Array, Object(lajax\translatemanager\controllers\LanguageController))
#28 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/Controller.php(371): yii\base\View->render('translate', Array, Object(lajax\translatemanager\controllers\LanguageController))
#29 /Users/Yura/PhpstormProjects/realty-admin/vendor/lajax/yii2-translate-manager/controllers/actions/TranslateAction.php(40): yii\base\Controller->render('translate', Array)
#30 [internal function]: lajax\translatemanager\controllers\actions\TranslateAction->run()
#31 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/Action.php(92): call_user_func_array(Array, Array)
#32 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\Action->runWithParams(Array)
#33 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('translate', Array)
#34 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('translatemanage...', Array)
#35 /Users/Yura/PhpstormProjects/realty-admin/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#36 /Users/Yura/PhpstormProjects/realty-admin/web/index.php(12): yii\base\Application->run()
#37 {main}
2015-09-30 16:02:01 [127.0.0.1][1][qkmdmv8gphir0r5op2ts870bs7][info][application] $_GET = [
    'LanguageSourceSearch' => [
        'category' => ''
        'message' => ''
        'translation' => 'язык'
    ]
    'language_id' => 'ru-RU'
]

$_COOKIE = [
    '_csrf' => '8a7e9866facfad41cac827ee244031e8ee2b4adee5d930bc734c68cba6548175a:2:{i:0;s:5:\"_csrf\";i:1;s:32:\"W5Vz9_EXKrXVOi_IPMbI58UpVXDOECc5\";}'
    'PHPSESSID' => 'qkmdmv8gphir0r5op2ts870bs7'
    '_identity' => '118bf8435d6762394b86d6dee0e57a8774b2f0e8f6f913a9f00b5a6ce7bb2eaaa:2:{i:0;s:9:\"_identity\";i:1;s:17:\"[1,false,2592000]\";}'
]

$_SESSION = [
    '__flash' => [
        'TM-language__id' => 1
    ]
    '__returnUrl' => '/'
    '__id' => 1
    'TM-language__id' => 'ru-RU'
]

$_SERVER = [
    'USER' => 'Yura'
    'HOME' => '/Users/Yura'
    'FCGI_ROLE' => 'RESPONDER'
    'SCRIPT_FILENAME' => '/Users/Yura/PhpstormProjects/realty-admin/web/index.php'
    'QUERY_STRING' => 'LanguageSourceSearch%5Bcategory%5D=&LanguageSourceSearch%5Bmessage%5D=&LanguageSourceSearch%5Btranslation%5D=%D1%8F%D0%B7%D1%8B%D0%BA&language_id=ru-RU'
    'REQUEST_METHOD' => 'GET'
    'CONTENT_TYPE' => ''
    'CONTENT_LENGTH' => ''
    'SCRIPT_NAME' => '/index.php'
    'REQUEST_URI' => '/translatemanager/language/translate?LanguageSourceSearch%5Bcategory%5D=&LanguageSourceSearch%5Bmessage%5D=&LanguageSourceSearch%5Btranslation%5D=%D1%8F%D0%B7%D1%8B%D0%BA&language_id=ru-RU'
    'DOCUMENT_URI' => '/index.php'
    'DOCUMENT_ROOT' => '/Users/Yura/PhpstormProjects/realty-admin/web'
    'SERVER_PROTOCOL' => 'HTTP/1.1'
    'GATEWAY_INTERFACE' => 'CGI/1.1'
    'SERVER_SOFTWARE' => 'nginx/1.8.0'
    'REMOTE_ADDR' => '127.0.0.1'
    'REMOTE_PORT' => '49863'
    'SERVER_ADDR' => '127.0.0.1'
    'SERVER_PORT' => '80'
    'SERVER_NAME' => 'admin.realty.local'
    'HTTP_HOST' => 'admin.realty.local'
    'HTTP_CONNECTION' => 'keep-alive'
    'HTTP_CACHE_CONTROL' => 'max-age=0'
    'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
    'HTTP_UPGRADE_INSECURE_REQUESTS' => '1'
    'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36'
    'HTTP_REFERER' => 'http://admin.realty.local/translatemanager/language/translate?language_id=ru-RU'
    'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, sdch'
    'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4'
    'HTTP_COOKIE' => '_csrf=8a7e9866facfad41cac827ee244031e8ee2b4adee5d930bc734c68cba6548175a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22W5Vz9_EXKrXVOi_IPMbI58UpVXDOECc5%22%3B%7D; PHPSESSID=qkmdmv8gphir0r5op2ts870bs7; _identity=118bf8435d6762394b86d6dee0e57a8774b2f0e8f6f913a9f00b5a6ce7bb2eaaa%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A17%3A%22%5B1%2Cfalse%2C2592000%5D%22%3B%7D'
    'PHP_SELF' => '/index.php'
    'REQUEST_TIME_FLOAT' => 1443610921.3072
    'REQUEST_TIME' => 1443610921
]


Hello, I wanted to override the module and override the views for my skin

Incomplete database configuration: columns in Backend

if (is_array($this->_tables)) {
foreach ($this->_tables as $tables) {
if (empty($tables['connection'])) {
throw new InvalidConfigException('Incomplete database configuration: connection ');
} else if (empty($tables['table'])) {
throw new InvalidConfigException('Incomplete database configuration: table ');
} else if (empty($tables['columns'])) {
throw new InvalidConfigException('Incomplete database configuration: columns ');
}
}
}

translate/scan

Good day,

I try ./yii translate/scan

and

Scanning translations...
PHP Notice 'yii\base\ErrorException' with message 'Trying to get property of non-object'

in /var/www/html/yii/vendor/lajax/yii2-translate-manager/services/Scanner.php:68

Stack trace:
#0 /var/www/html/yii/vendor/lajax/yii2-translate-manager/services/Scanner.php(68): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/var/www/html/g...', 68, Array)
#1 /var/www/html/yii/vendor/lajax/yii2-translate-manager/commands/TranslatemanagerController.php(37): lajax\translatemanager\services\Scanner->run()
#2 [internal function]: lajax\translatemanager\commands\TranslatemanagerController->actionScan()
#3 /var/www/html/yii/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#4 /var/www/html/yii/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#5 /var/www/html/yii/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('scan', Array)
#6 /var/www/html/yii/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('scan', Array)
#7 /var/www/html/yii/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('translate/scan', Array)
#8 /var/www/html/yii/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('translate/scan', Array)
#9 /var/www/html/yii/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#10 /var/www/html/yii/yii(19): yii\base\Application->run()
#11 {main}

use Translate Manager module with postgresql.

Hi. I'm using your great module on postgresql db. And it's all good except 2 places where table params are escaping with mysql quotes ( ` ).

Those are in Language model getGridStatistic action:

 $languages = Language::find()
                    ->select('language_id, COUNT( `lt`.`id` ) AS `status`')
                    ->leftJoin(LanguageTranslate::tableName() . ' AS `lt`', '`language`.`language_id` = `lt`.`language`')
                    ->groupBy('language_id')
                    ->all();

And namespace lajax\translatemanager\services; class Generator

 private function _getLanguageItems() {
        $this->_languageItems = LanguageSource::find()->joinWith([
                'languageTranslate' => function ($query) {
                        $query->where('language_translate.language = :language', [':language' => $this->_languageId]);
                    }
                ])->where('`category` = :category', [':category' => 'javascript'])->all();
    }

For postgresql usage, those quotes can be removed or use some Yii functionality ( I'm noob so i can't make pull request sorry).

Thanks in advance.
Great module.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.