Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove double-pluralization from getAllResourcePermissions #465

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

dissto
Copy link

@dissto dissto commented Dec 11, 2024

Problem

getAllResourcePermissions() is currently running the already pluralized Resource::getPluralModelLabel() through ->plural() again which causes issues in non-english languages. See the german example below.

->prepend(
    str($resourceEntity['fqcn']::getPluralModelLabel())
        ->plural()
        ->title()
        ->append(' - ')
        ->toString()

Example

German example:

Singular Plural Expected output Actual output
Kunde Kunden Kunden ✅ Kundens ❌
Lieferant Lieferanten Lieferanten ✅ Lieferantens ❌

English example:

Singular Plural Expected output Actual output
Customer Customers Customers ✅ Customers ✅
User Users Users ✅ Users ✅

Fix

The fix seems to be straight forward since Filament internally already properly pluralizes the getPluralModelLabel()

  ->prepend(
      str($resourceEntity['fqcn']::getPluralModelLabel())
-         ->plural()
          ->title()
          ->append(' - ')
          ->toString()

Reference

Before

Screenshot 2024-12-11 230507

Screenshot 2024-12-11 230604

After

Screenshot 2024-12-11 230431

Screenshot 2024-12-11 230622

Copy link

what-the-diff bot commented Dec 11, 2024

PR Summary

  • Improvement in Resource Permission Function
    The changes made help to simplify the process of identifying resources. Previously, a function was including an unnecessary step where it tried to change the name of a resource to its plural form. This has now been removed improving the efficiency of the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant