Skip to content

Commit dc219c9

Browse files
committed
Clean up PHP warnings
Noticed them while checking my test server
1 parent 591d3f3 commit dc219c9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

app/models/mainsearch_glossary.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
// Limit results to 200
1717
array_splice($locale1_strings, 200);
1818

19-
// Get the locale results
20-
$results = [];
21-
22-
foreach ($locale1_strings as $key => $str) {
23-
$results[$key] = $tmx_target[$key];
24-
}
25-
2619
$perfect = $imperfect = [];
2720

2821
// We want to test compound words as well, /ex: 'switch to'
@@ -77,7 +70,7 @@ function ($element) use ($word) {
7770
$get_results = function ($arr) use ($tmx_target) {
7871
$results = [];
7972
foreach ($arr as $val) {
80-
if ($tmx_target[$val] != '') {
73+
if (isset($tmx_target[$val]) && $tmx_target[$val] != '') {
8174
$results[$val] = $tmx_target[$val];
8275
}
8376
}

app/views/gaia.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,23 @@ function ($str) {
309309
. '</tr>';
310310

311311
foreach ($common_keys as $key => $val) {
312+
$get_localized_string = function ($id) use ($key, $strings) {
313+
// Avoid warnings if the string is not localized
314+
315+
return isset($strings[$id][$key]) ?
316+
$strings[$id][$key] :
317+
'<em class="error">missing string</em>';
318+
};
312319
if (trim(strtolower($strings[$englishchanges[0] . '-en-US'][$key])) != trim(strtolower($strings[$englishchanges[1] . '-en-US'][$key]))) {
313320
$table .=
314321
'<tr>'
315322
. '<td><span class="celltitle">Key</span><div class="string">' . ShowResults::formatEntity($key) . '</div></td>'
316323
. '<td><span class="celltitle">Gaia' . $repo_one . '</span><div class="string">'
317324
. ShowResults::highlight(Utils::secureText($strings[$englishchanges[0] . '-en-US'][$key]), 'en-US')
318-
. '<br><small>' . Utils::secureText($strings[$englishchanges[0]][$key]) . '</small></div></td>'
325+
. '<br><small>' . $get_localized_string($englishchanges[0]) . '</small></div></td>'
319326
. '<td><span class="celltitle">Gaia' . $repo_two . '</span><div class="string">'
320327
. ShowResults::highlight(Utils::secureText($strings[$englishchanges[1] . '-en-US'][$key]), 'en-US')
321-
. '<br><small>' . Utils::secureText($strings[$englishchanges[1]][$key]) . '</small></div></td>'
328+
. '<br><small>' . $get_localized_string($englishchanges[1]) . '</small></div></td>'
322329
. '</tr>';
323330
}
324331
}

0 commit comments

Comments
 (0)