Skip to content

Commit

Permalink
Made motranslator vendor optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfoot90 committed Feb 1, 2017
1 parent 59f39f9 commit ff12d2e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ $query2 = $statement->build();
var_dump($query2); // outputs string(19) "SELECT * FROM "b" "
```

## Localization

You can localize error messages installing `phpmyadmin/motranslator` version `3.0` or newer:
```sh
composer require phpmyadmin/motranslator:^3.0
```

The locale is automatically detected from your enrivonment, you can also set a different locale

**From cli**:
```sh
LC_ALL=pl ./vendor/bin/lint-query --query "SELECT 1"
```

**From php**:
```php
require __DIR__."/vendor/autoload.php";

$GLOBALS['lang'] = 'pl';

$query1 = "select * from a";
$parser = new PhpMyAdmin\SqlParser\Parser($query1);
```

## More information

This library was originally created during the Google Summer of Code 2015 and has been used by phpMyAdmin since version 4.5.
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
},
"require": {
"php": ">=5.3.0",
"phpmyadmin/motranslator": "~3.0",
"ext-mbstring": "*"
},
"conflict": {
"phpmyadmin/motranslator": "<3.0"
},
"suggest": {
"phpmyadmin/motranslator": "Translate messages to your favorite locale"
},
"require-dev": {
"phpunit/php-code-coverage": "~2.0 || ~3.0",
"phpunit/phpunit": "~4.8 || ~5.1"
Expand Down
4 changes: 4 additions & 0 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public static function load()
*/
public static function gettext($msgid)
{
if (!class_exists('\PhpMyAdmin\MoTranslator\Loader', true)) {
return $msgid;
}

self::load();

return self::$translator->gettext($msgid);
Expand Down

0 comments on commit ff12d2e

Please sign in to comment.