Skip to content

Commit df19d84

Browse files
committed
Add support for RTL languages
1 parent 83017f9 commit df19d84

File tree

3 files changed

+73
-7
lines changed

3 files changed

+73
-7
lines changed

src/Views/exceptions/development.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@
160160
border-right: 2px solid #222;
161161
}
162162

163+
.rtl th {
164+
border-left: 2px solid #222;
165+
border-right: 0;
166+
}
167+
163168
th, td {
164169
border-bottom: 1px solid #222;
165170
padding: 5px;
@@ -179,12 +184,21 @@
179184
text-align: left;
180185
}
181186

187+
.rtl thead th {
188+
border-left: 0;
189+
text-align: right;
190+
}
191+
182192
tbody th {
183193
background: #111;
184194
min-width: 40%;
185195
text-align: right;
186196
}
187197

198+
.rtl tbody th {
199+
text-align: left;
200+
}
201+
188202
tbody tr:hover th,
189203
tr:hover {
190204
background: #333;
@@ -231,7 +245,7 @@
231245
}
232246
</style>
233247
</head>
234-
<body class="aplus-debug">
248+
<body class="aplus-debug <?= $handler->getLanguage()->getCurrentLocaleDirection() ?>">
235249
<header class="top">
236250
<small><?= $lang('exception') ?>:</small>
237251
<h1><?= $exception::class ?></h1>
@@ -279,7 +293,7 @@
279293
<?php foreach ($traces as $key => $trace) : ?>
280294
<?php if (isset($trace['file'])) : ?>
281295
<?php if (is_readable($trace['file'])) : ?>
282-
<dl>
296+
<dl dir="ltr">
283297
<dt>
284298
<span><?= count($traces) - $key ?></span>
285299
<?= $trace['file'] ?><?=
@@ -410,7 +424,7 @@
410424
</tr>
411425
<tr>
412426
<th><?= $lang('message') ?></th>
413-
<td>
427+
<td dir="ltr">
414428
<pre><code class="language-log"><?= htmlentities($log->message) ?></code></pre>
415429
</td>
416430
</tr>

src/Views/exceptions/production.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
};
1414

1515
$log = $handler->getLog();
16+
$isRtl = $handler->getLanguage()->getCurrentLocaleDirection() === 'rtl';
1617
?>
1718
<!doctype html>
1819
<html lang="<?= $handler->getLanguage()->getCurrentLocale() ?>" dir="<?= $handler->getLanguage()
@@ -52,10 +53,17 @@
5253
<h1><?= $lang('exceptionTitle') ?></h1>
5354
<p><?= $lang('exceptionDescription') ?></p>
5455
<?php if ($log) : ?>
55-
<p><?= $lang('logId') ?>: <span class="log-id"
56-
title="<?= htmlentities($lang('clickToCopyLogId')) ?>"
57-
><?= htmlentities($log->id) ?></span>
58-
</p>
56+
<?php if ($isRtl) : ?>
57+
<p><span class="log-id"
58+
title="<?= htmlentities($lang('clickToCopyLogId')) ?>"
59+
><?= htmlentities($log->id) ?></span> :<?= $lang('logId') ?>
60+
</p>
61+
<?php else : ?>
62+
<p><?= $lang('logId') ?>: <span class="log-id"
63+
title="<?= htmlentities($lang('clickToCopyLogId')) ?>"
64+
><?= htmlentities($log->id) ?></span>
65+
</p>
66+
<?php endif ?>
5967
<script>
6068
document.querySelector('.log-id').onclick = function () {
6169
navigator.clipboard.writeText(this.innerText);

tests/ExceptionHandlerTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,50 @@ public function testAddAndRemoveHiddenInput() : void
383383
);
384384
}
385385

386+
/**
387+
* @runInSeparateProcess
388+
*
389+
* @dataProvider environmentsProvider
390+
*/
391+
public function testExceptionsWithLtrLanguage(string $environment) : void
392+
{
393+
$_POST = ['foo' => 'bar'];
394+
$language = new Language('en', [__DIR__ . '/../src/Languages']);
395+
$exceptions = new ExceptionHandlerMock(
396+
$environment,
397+
$this->getLogger(),
398+
$language
399+
);
400+
$exceptions->cli = false;
401+
$exceptions->setHiddenInputs('$_POST');
402+
\ob_start();
403+
$exceptions->exceptionHandler(new \Exception('Foo'));
404+
$contents = (string) \ob_get_clean();
405+
self::assertStringContainsString('dir="ltr"', $contents);
406+
}
407+
408+
/**
409+
* @runInSeparateProcess
410+
*
411+
* @dataProvider environmentsProvider
412+
*/
413+
public function testExceptionsWithRtlLanguage(string $environment) : void
414+
{
415+
$_POST = ['foo' => 'bar'];
416+
$language = new Language('he', [__DIR__ . '/../src/Languages']);
417+
$exceptions = new ExceptionHandlerMock(
418+
$environment,
419+
$this->getLogger(),
420+
$language
421+
);
422+
$exceptions->cli = false;
423+
$exceptions->setHiddenInputs('$_POST');
424+
\ob_start();
425+
$exceptions->exceptionHandler(new \Exception('Foo'));
426+
$contents = (string) \ob_get_clean();
427+
self::assertStringContainsString('dir="rtl"', $contents);
428+
}
429+
386430
/**
387431
* @return array<array<string>>
388432
*/

0 commit comments

Comments
 (0)