Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
},
"require": {
"php": ">=5.3.0",
"phpmyadmin/motranslator": "~3.0",
"ext-mbstring": "*"
},
"require-dev": {
"phpmyadmin/motranslator": "~3.0",
"phpunit/php-code-coverage": "~2.0 || ~3.0",
"phpunit/phpunit": "~4.8 || ~5.1"
},
"conflict": {
"phpmyadmin/motranslator": "<3.0"
},
"suggest": {
"phpmyadmin/motranslator": "Translate messages to your favorite locale"
},
"bin": [
"bin/highlight-query",
"bin/lint-query"
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