Skip to content

Commit 997ab9d

Browse files
authored
Merge pull request #696 from ByteHunter/add-translations
Mark strings for translations
2 parents 5774826 + 03f3fc6 commit 997ab9d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/Authenticator/AuthenticationRequiredException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Authentication\Authenticator;
1818

1919
use Cake\Http\Exception\HttpException;
20+
use function Cake\I18n\__d;
2021

2122
/**
2223
* An exception for stateless authenticators when credentials are wrong/missing.
@@ -45,7 +46,7 @@ class AuthenticationRequiredException extends HttpException
4546
*/
4647
public function __construct(array $headers, string $body = '', int $code = 401)
4748
{
48-
parent::__construct('Authentication is required to continue', $code);
49+
parent::__construct(__d('authentication', 'Authentication is required to continue'), $code);
4950
$this->headers = $headers;
5051
$this->body = $body;
5152
}

src/Authenticator/UnauthenticatedException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use Cake\Http\Exception\HttpException;
2020
use Throwable;
21+
use function Cake\I18n\__d;
2122

2223
/**
2324
* An exception that signals that authentication was required but missing.
@@ -38,7 +39,7 @@ class UnauthenticatedException extends HttpException
3839
public function __construct(string $message = '', int $code = 401, ?Throwable $previous = null)
3940
{
4041
if (!$message) {
41-
$message = 'Authentication is required to continue';
42+
$message = __d('authentication', 'Authentication is required to continue');
4243
}
4344
parent::__construct($message, $code, $previous);
4445
}

tests/bootstrap.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
use Authentication\Plugin as AuthenticationPlugin;
18+
use Cake\Cache\Cache;
1819
use Cake\Core\Configure;
1920
use Cake\Core\Plugin;
2021
use Cake\Datasource\ConnectionManager;
@@ -54,6 +55,12 @@
5455
],
5556
]);
5657

58+
Cache::setConfig([
59+
'_cake_translations_' => [
60+
'engine' => 'Array',
61+
],
62+
]);
63+
5764
if (!getenv('DB_URL')) {
5865
putenv('DB_URL=sqlite:///:memory:');
5966
}

0 commit comments

Comments
 (0)