Skip to content

Fixed admin:user:create failing when admin role has different name … #2651

Fixed admin:user:create failing when admin role has different name …

Fixed admin:user:create failing when admin role has different name … #2651

name: Locale CSV Sorting Check
on:
push:
branches:
- main
pull_request:
workflow_call:
workflow_dispatch:
jobs:
check-csv-sorting:
runs-on: ubuntu-latest
name: Check CSV files are sorted alphabetically
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Check CSV sorting
run: |
# Run the PHP sorting command
php -r '
foreach (glob("app/locale/en_US/*.csv") as $file) {
$lines = file($file, FILE_IGNORE_NEW_LINES);
usort($lines, function($a, $b) {
$a = str_getcsv($a)[0] ?? "";
$b = str_getcsv($b)[0] ?? "";
return strnatcasecmp($a, $b);
});
file_put_contents($file, implode(PHP_EOL, $lines) . PHP_EOL);
}
'
# Check if any files were modified
if ! git diff --quiet app/locale/en_US/; then
echo "❌ Some CSV files are not sorted alphabetically"
echo ""
echo "Files that need sorting:"
git diff --name-only app/locale/en_US/
echo ""
echo "Differences found:"
git diff app/locale/en_US/
echo ""
echo "Please run the following command to fix them:"
echo ""
echo "php -r '"
echo " foreach (glob(\"app/locale/en_US/*.csv\") as \$file) {"
echo " \$lines = file(\$file, FILE_IGNORE_NEW_LINES);"
echo " usort(\$lines, function(\$a, \$b) {"
echo " \$a = str_getcsv(\$a)[0] ?? \"\";"
echo " \$b = str_getcsv(\$b)[0] ?? \"\";"
echo " return strnatcasecmp(\$a, \$b);"
echo " });"
echo " file_put_contents(\$file, implode(PHP_EOL, \$lines) . PHP_EOL);"
echo " }"
echo "'"
echo ""
exit 1
else
echo "✅ All CSV files are correctly sorted"
fi