Skip to content

Add pluralization - #2520

Draft
samuelwei wants to merge 9 commits into
developfrom
add-pluralization
Draft

Add pluralization#2520
samuelwei wants to merge 9 commits into
developfrom
add-pluralization

Conversation

@samuelwei

Copy link
Copy Markdown
Collaborator

Fixes #

Type

  • Bugfix
  • Feature
  • Documentation
  • Refactoring (e.g. Style updates, Test implementation, etc.)
  • Other (please describe):

Checklist

  • Code updated to current develop branch head
  • Passes CI checks
  • Is a part of an issue
  • Tests added for the bugfix or newly implemented feature, describe below why if not
  • Changelog is updated
  • Documentation of code and features exists

Changes

Other information

@coderabbitai

coderabbitai Bot commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 455ae953-5d6e-4c4e-bda8-3614c45e92c2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-pluralization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 10, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.06%. Comparing base (57009ac) to head (9eb709d).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
resources/js/i18n.js 68.00% 8 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2520      +/-   ##
=============================================
- Coverage      97.10%   97.06%   -0.05%     
  Complexity      1949     1949              
=============================================
  Files            483      483              
  Lines          16656    16686      +30     
  Branches        2408     2418      +10     
=============================================
+ Hits           16174    16196      +22     
- Misses           482      490       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cypress

cypress Bot commented Oct 10, 2025

Copy link
Copy Markdown

PILOS    Run #3219

Run Properties:  status check passed Passed #3219  •  git commit 9eb709db16: Add pluralization
Project PILOS
Branch Review add-pluralization
Run status status check passed Passed #3219
Run duration 08m 08s
Commit git commit 9eb709db16: Add pluralization
Committer Samuel Weirich
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 635
View all changes introduced in this branch ↗︎

@samuelwei
samuelwei force-pushed the develop branch 2 times, most recently from 88ee280 to bc9287a Compare October 20, 2025 15:17
@samuelwei samuelwei mentioned this pull request Apr 24, 2026
6 tasks
@samuelwei
samuelwei requested a review from Sabr1n4W June 10, 2026 14:02
Copilot AI review requested due to automatic review settings July 27, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds frontend support for Laravel-style pluralization in localized strings and uses it to display a more informative “Too many requests” message based on the Retry-After header, alongside documentation updates explaining placeholders/pluralization.

Changes:

  • Extend the custom vue-i18n message compiler to support Laravel pluralization formats ({n}, [n,m], *) and placeholder replacement with :placeholder.
  • Update the 429 “Too many requests” handler to compute a wait time in minutes and pass it into the translation.
  • Update localization documentation and README localization section.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
resources/js/services/Api.js Passes retry delay into the “too many requests” toast.
resources/js/i18n.js Adds pluralization parsing and switches placeholder replacement to replaceAll.
README.md Points contributors to localization documentation.
lang/en/app.php Converts too_many_requests to a pluralizable string with :count.
docs/docs/administration/09-customisation/02-locales.md Documents placeholders and pluralization format and contribution flow.
Comments suppressed due to low confidence (1)

resources/js/i18n.js:50

  • getPluralization attempts to match each plural segment from the start of the string, but Laravel-style plural strings are commonly written with spaces around the pipe (e.g. "{1} ... | [2,*] ..."). In that case part will start with whitespace and the regex won’t match, causing the function to fall back to the full unparsed message.

Trim each part before matching.

  for (const part of messageParts) {
    const match = part.match(regex);
    if (match) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread resources/js/services/Api.js
Comment thread resources/js/i18n.js
Copilot AI review requested due to automatic review settings July 30, 2026 06:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (6)

resources/js/i18n.js:25

  • The message compiler mutates the captured message template (pluralization + placeholder replacement). Because vue-i18n caches the compiled function per key, later translations can return stale text (e.g., first plural form/placeholder values “stick”), and replaceAll(":n", ...) can also corrupt other placeholders like :name / :numberOfSelectedUsers.

Build a per-call rendered string and use a boundary-safe replacement so :n doesn’t match the start of longer placeholders.

      // If ctx.values has n or count property, we have to handle pluralization
      if (ctx.values["n"] !== undefined) {
        message = getPluralization(message, ctx.values["n"]);
      } else if (ctx.values["count"] !== undefined) {
        message = getPluralization(message, ctx.values["count"]);

resources/js/views/RoomsView.vue:148

  • $t("rooms.auth_throttled", authThrottledFor) assumes the new pluralization format that uses :count, but the other locale files still use :try_again (e.g. lang/de/rooms.php, lang/fr/rooms.php, etc.). In those locales the placeholder will no longer be replaced and will show up in the UI.

To avoid breaking non-English locales, migrate rooms.auth_throttled in all locales to the new pluralization + :count syntax (or keep the placeholder key consistent across locales).

                  v-if="authThrottledFor > 0"
                  class="mt-1 text-red-500"
                  role="alert"
                >
                  {{ $t("rooms.auth_throttled", authThrottledFor) }}
                </p>

resources/js/views/Login.vue:210

  • t("auth.throttle", retryAfter) now relies on the pluralization/count-based frontend syntax, but the non-English locale files still use the old :seconds placeholder (e.g. lang/de/auth.php, lang/fr/auth.php, etc.). With the current change those locales will render :seconds literally.

Either migrate the other locales to the new :count + pluralization format, or keep the placeholder name consistent across locales.

        const retryAfter = Number(error.response.headers["retry-after"]);
        if (data.username) {
          errors[id] = {
            username: [t("auth.throttle", retryAfter)],
          };
        } else {
          errors[id] = { email: [t("auth.throttle", retryAfter)] };
        }

resources/js/components/RoomTabMembersBulkEditButton.vue:6

  • These translations now pass a count for pluralization, but several non-English locale strings for the same keys still use the legacy :numberOfSelectedUsers placeholder (e.g. lang/de/rooms.php:210, :247, etc.). Those locales will render :numberOfSelectedUsers literally after this change.

To prevent breaking existing locales, migrate the corresponding keys in lang/*/rooms.php to the new pluralization format using :count.

  <Button
    v-tooltip="$t('rooms.members.bulk_edit_user', props.userIds.length)"
    data-test="room-members-bulk-edit-button"
    :aria-label="$t('rooms.members.bulk_edit_user', props.userIds.length)"
    :disabled="disabled"

resources/js/components/RoomTabMembersBulkDeleteButton.vue:6

  • Same issue as the bulk edit button: non-English locale files still use :numberOfSelectedUsers for these keys (e.g. lang/de/rooms.php:212, :251, :253). With the new count-based pluralization calls, those locales will show the placeholder text instead of the selected member count.

Please migrate the affected locale strings to the new pluralization format using :count to keep all locales working.

  <Button
    v-tooltip="$t('rooms.members.bulk_remove_user', props.userIds.length)"
    data-test="room-members-bulk-delete-button"
    :aria-label="$t('rooms.members.bulk_remove_user', props.userIds.length)"
    :disabled="disabled"

resources/js/components/RoomDetailsList.vue:85

  • meetings.participant_count_value was added only to lang/en/meetings.php. Other locales don’t define this key, so non-English users will see a missing-translation fallback for participant count.

Either add participant_count_value to all locales (preferred), or keep using the existing meetings.participant_count key until the other locales are updated.

        <span>
          {{
            $t(
              "meetings.participant_count_value",
              props.room.last_meeting.usage.participant_count,
            )
          }}</span

Copilot AI review requested due to automatic review settings July 30, 2026 12:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 30, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 30, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

3 participants