Skip to content

Commit a1ffa56

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents aad9eac + f502863 commit a1ffa56

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,30 @@ $query2 = $statement->build();
8686
var_dump($query2); // outputs string(19) "SELECT * FROM "b" "
8787
```
8888

89+
## Localization
90+
91+
You can localize error messages installing `phpmyadmin/motranslator` version `3.0` or newer:
92+
```sh
93+
composer require phpmyadmin/motranslator:^3.0
94+
```
95+
96+
The locale is automatically detected from your enrivonment, you can also set a different locale
97+
98+
**From cli**:
99+
```sh
100+
LC_ALL=pl ./vendor/bin/lint-query --query "SELECT 1"
101+
```
102+
103+
**From php**:
104+
```php
105+
require __DIR__."/vendor/autoload.php";
106+
107+
$GLOBALS['lang'] = 'pl';
108+
109+
$query1 = "select * from a";
110+
$parser = new PhpMyAdmin\SqlParser\Parser($query1);
111+
```
112+
89113
## More information
90114

91115
This library was originally created during the Google Summer of Code 2015 and has been used by phpMyAdmin since version 4.5.

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@
1717
},
1818
"require": {
1919
"php": ">=5.3.0",
20-
"phpmyadmin/motranslator": "~3.0",
2120
"ext-mbstring": "*"
2221
},
2322
"require-dev": {
23+
"phpmyadmin/motranslator": "~3.0",
2424
"phpunit/php-code-coverage": "~2.0 || ~3.0",
2525
"phpunit/phpunit": "~4.8 || ~5.1"
2626
},
27+
"conflict": {
28+
"phpmyadmin/motranslator": "<3.0"
29+
},
30+
"suggest": {
31+
"phpmyadmin/motranslator": "Translate messages to your favorite locale"
32+
},
2733
"bin": [
2834
"bin/highlight-query",
2935
"bin/lint-query"

src/Translator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public static function load()
5858
*/
5959
public static function gettext($msgid)
6060
{
61+
if (!class_exists('\PhpMyAdmin\MoTranslator\Loader', true)) {
62+
return $msgid;
63+
}
64+
6165
self::load();
6266

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

0 commit comments

Comments
 (0)