Skip to content

Add locale-aware inventory sorting via PHP Collator (mirrors FreshRSS#8985)#1

Open
mo74m3ed with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-missing-feed-icons
Open

Add locale-aware inventory sorting via PHP Collator (mirrors FreshRSS#8985)#1
mo74m3ed with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-missing-feed-icons

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown

strnatcasecmp() compares raw UTF-8 bytes, so accented names (Ábaco, Ñandú) sort after all ASCII names regardless of locale. Replaces byte-order comparison with PHP's Collator (ext-intl) so inventory names sort correctly for the application locale, with a strnatcasecmp fallback when ext-intl is unavailable.

Changes

  • app/Helpers/LocaleHelper (new) — static localeCompare(string $a, string $b): int using Collator::create(app()->getLocale()) with NUMERIC_COLLATION enabled; caches the collator statically; falls back to strnatcasecmp(); exposes resetCollator() for test isolation.

  • app/Actions/Inventory/InventoryListAction — fetches all records, sorts globally via uasort + LocaleHelper::localeCompare(), then paginates manually. Per-page limit clamped to MAX_PER_PAGE = 100; limits extracted to class constants.

  • tests/Unit/LocaleHelperTest (new) — covers less/equal/greater comparisons and the Spanish accent ordering case.

Before (en/byte-order): banana, Manzana, nube, Zorro, Ábaco, Ñandú, Úlcera, árbol
After  (es/Collator):   Ábaco, árbol, banana, Manzana, nube, Ñandú, Úlcera, Zorro

Copilot AI changed the title Add locale-aware inventory sorting via LocaleHelper (mirrors FreshRSS#8985) Add locale-aware inventory sorting via PHP Collator (mirrors FreshRSS#8985) Jul 7, 2026
Copilot AI requested a review from mo74m3ed July 7, 2026 18:40
@mo74m3ed
mo74m3ed marked this pull request as ready for review July 10, 2026 04:18
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.

2 participants