Skip to content

Commit 5014e52

Browse files
committed
fix: use translated strings for category restriction UI messages
Hardcoded English strings in the JS bypassed the translation system. Added translation keys and data attributes on the template container so the TypeScript reads localized text instead of embedding English.
1 parent 5875b4c commit 5014e52

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

phpmyfaq/admin/assets/src/group/groups.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ const renderCategoryRestrictions = (container: HTMLElement): void => {
338338
container.innerHTML = '';
339339

340340
if (checkedRights.length === 0) {
341-
container.innerHTML = '<p class="text-muted">No permissions assigned to this group.</p>';
341+
const emptyMsg = container.dataset.msgEmpty || 'No permissions assigned to this group.';
342+
container.innerHTML = `<p class="text-muted">${emptyMsg}</p>`;
342343
return;
343344
}
344345

@@ -373,7 +374,9 @@ const renderCategoryRestrictions = (container: HTMLElement): void => {
373374

374375
const helpText = document.createElement('div');
375376
helpText.className = 'form-text';
376-
helpText.textContent = 'Select categories to restrict this permission. Leave empty for unrestricted access.';
377+
helpText.textContent =
378+
container.dataset.msgHelp ||
379+
'Select categories to restrict this permission. Leave empty for unrestricted access.';
377380
wrapper.appendChild(helpText);
378381

379382
container.appendChild(wrapper);

phpmyfaq/assets/templates/admin/user/group.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@
209209
<h5 class="card-header py-3">
210210
<i aria-hidden="true" class="bi bi-folder-check"></i> {{ 'ad_group_category_restrictions' | translate }}
211211
</h5>
212-
<div class="card-body" id="categoryRestrictionsBody">
212+
<div class="card-body" id="categoryRestrictionsBody"
213+
data-msg-empty="{{ 'ad_group_no_permissions' | translate }}"
214+
data-msg-help="{{ 'ad_group_category_restrictions_select' | translate }}">
213215
<p class="text-muted">{{ 'ad_group_category_restrictions_help' | translate }}</p>
214216
</div>
215217
<div class="card-footer">

phpmyfaq/translations/language_en.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,5 +1717,7 @@
17171717
// added v4.2.0-alpha.2 - 2026-03-15 by Thorsten
17181718
$PMF_LANG['ad_group_category_restrictions'] = 'Category Restrictions';
17191719
$PMF_LANG['ad_group_category_restrictions_help'] = 'Select a group to manage category restrictions for its permissions.';
1720+
$PMF_LANG['ad_group_no_permissions'] = 'No permissions assigned to this group.';
1721+
$PMF_LANG['ad_group_category_restrictions_select'] = 'Select categories to restrict this permission. Leave empty for unrestricted access.';
17201722

17211723
return $PMF_LANG;

0 commit comments

Comments
 (0)