Skip to content

fix(transloco): grammar fix misspelled scope hint error message#904

Open
focbenz wants to merge 2 commits intojsverse:masterfrom
focbenz:typo-fix-scope-misspelled-hint
Open

fix(transloco): grammar fix misspelled scope hint error message#904
focbenz wants to merge 2 commits intojsverse:masterfrom
focbenz:typo-fix-scope-misspelled-hint

Conversation

@focbenz
Copy link

@focbenz focbenz commented Mar 10, 2026

Error message displayed when a scoped lang fails to load AND all fallbacks fail:
Unable to load translation and all the fallback languages, did you misspelled the scope name?
VVV
Unable to load translation and all the fallback languages, did you misspell the scope name?

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe: typo fix without previous bug report

What is the current behavior?

Error message displayed when a scoped lang fails to load AND all fallbacks fail:
Unable to load translation and all the fallback languages, did you misspelled the scope name?

Issue Number: N/A

What is the new behavior?

The error message hint now reads:
Unable to load translation and all the fallback languages, did you misspell the scope name?

Does this PR introduce a breaking change?

  • Yes
  • No

Summary by cubic

Fixed the scope hint grammar in TranslocoService when a scoped language fails and all fallbacks fail. Added a test that simulates the scoped load + fallback failure and asserts "did you misspell the scope name?".

Written for commit 06bc3c9. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed wording in the error shown when a translation scope fails to load and no fallbacks are available — message now clearly suggests a possibly misspelled scope name.
  • Tests

    • Added test coverage for a failed scoped translation load with all fallback attempts failing, verifying the error text and loader sequencing.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 10, 2026

Open in StackBlitz

@jsverse/transloco

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco@904

@jsverse/transloco-locale

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-locale@904

@jsverse/transloco-messageformat

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-messageformat@904

@jsverse/transloco-optimize

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-optimize@904

@jsverse/transloco-persist-lang

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-persist-lang@904

@jsverse/transloco-persist-translations

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-persist-translations@904

@jsverse/transloco-preload-langs

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-preload-langs@904

@jsverse/transloco-schematics

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-schematics@904

@jsverse/transloco-scoped-libs

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-scoped-libs@904

@jsverse/transloco-utils

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-utils@904

@jsverse/transloco-validator

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-validator@904

commit: 06bc3c9

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="libs/transloco/src/lib/tests/service/fallbacks.spec.ts">

<violation number="1" location="libs/transloco/src/lib/tests/service/fallbacks.spec.ts:156">
P0: The test asserts the old, ungrammatical string `'did you misspelled the scope name'`, but the source code was fixed to `'did you misspell the scope name?'`. This test will always fail.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

Adds a unit test verifying behavior when a scoped translation and its fallbacks all fail, and corrects a grammatical typo in the fallback-failure error message.

Changes

Cohort / File(s) Summary
Fallback test
libs/transloco/src/lib/tests/service/fallbacks.spec.ts
Adds a test that simulates a failed scoped-language load with no valid fallbacks, asserting the emitted error message contains a hint about a possibly misspelled scope and verifying the loader attempt sequence.
Error message grammar
libs/transloco/src/lib/transloco.service.ts
Edits the fallback-failure error text to replace "did you misspelled the scope name?" with "did you misspell the scope name?" (no behavioral changes).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through failing loads tonight,
sniffed a scope that hid from sight,
a tiny typo made me pause—
"misspell" fixed with careful claws. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: fixing a grammar error in an error message hint related to misspelled scope names.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description is mostly complete with all required template sections filled out, including PR Type (Bugfix selected), current behavior, new behavior, breaking change status, and checklist confirmations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/transloco/src/lib/tests/service/fallbacks.spec.ts`:
- Around line 155-157: The test assertion in the catchError block checks for the
outdated message 'did you misspelled the scope name' — update the expectation in
the test (the expect(...).toContain call inside the catchError callback in
fallbacks.spec.ts) to match the corrected service message 'did you misspell the
scope name?' so the test compares against the exact new text used by the
transloco service.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c2bd724e-ac45-44ab-b7c3-1ae068e44b9c

📥 Commits

Reviewing files that changed from the base of the PR and between 7989622 and 70d8252.

📒 Files selected for processing (2)
  • libs/transloco/src/lib/tests/service/fallbacks.spec.ts
  • libs/transloco/src/lib/transloco.service.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
libs/transloco/src/lib/tests/service/fallbacks.spec.ts (1)

141-164: Consider adding verification that the error was actually caught.

The test relies on catchError being triggered, but if the error path isn't reached (e.g., due to unexpected loader behavior), the test would pass without any assertion executing. The similar test at lines 111-139 includes an additional assertion outside catchError (expect(service.load).toHaveBeenCalledTimes(2)).

♻️ Suggested improvement
     it(`GIVEN a scoped lang that fails to load AND all fallbacks fail
     THEN the error should contain a scope misspelling hint`, fakeAsync(() => {
       const service = createService(
         {
           prodMode: false, // Show error messages in thrown errors
           fallbackLang: 'fallbackNotExists',
           failedRetries: 0,
         },
         { loader },
       );
 
+      spyOn(service, 'load').and.callThrough();
+      let errorCaught = false;
       service
         .load('admin/notExists')
         .pipe(
           catchError((err) => {
+            errorCaught = true;
             expect(err.message).toContain('did you misspell the scope name');
             return of('');
           }),
         )
         .subscribe();
 
       // admin/notExists will try 1 time then fallback 1 time
       runLoader(2);
+      expect(errorCaught).toBe(true);
+      expect(service.load).toHaveBeenCalledTimes(2);
     }));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/transloco/src/lib/tests/service/fallbacks.spec.ts` around lines 141 -
164, The test may pass without verifying the error path executed; ensure the
catchError branch actually ran by adding an assertion outside the catchError
(e.g., expect(loader.get).toHaveBeenCalledTimes(2) or increment a local flag
inside catchError and assert the flag is 1 after runLoader) so you explicitly
verify service.load('admin/notExists') attempted loading/fallbacks; reference
the existing symbols service.load, loader (or loader.get), and runLoader to
locate where to add the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@libs/transloco/src/lib/tests/service/fallbacks.spec.ts`:
- Around line 141-164: The test may pass without verifying the error path
executed; ensure the catchError branch actually ran by adding an assertion
outside the catchError (e.g., expect(loader.get).toHaveBeenCalledTimes(2) or
increment a local flag inside catchError and assert the flag is 1 after
runLoader) so you explicitly verify service.load('admin/notExists') attempted
loading/fallbacks; reference the existing symbols service.load, loader (or
loader.get), and runLoader to locate where to add the assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4221894d-d09a-4709-8174-5220c6148287

📥 Commits

Reviewing files that changed from the base of the PR and between 70d8252 and 397b0d1.

📒 Files selected for processing (1)
  • libs/transloco/src/lib/tests/service/fallbacks.spec.ts

@focbenz focbenz force-pushed the typo-fix-scope-misspelled-hint branch from 397b0d1 to 06bc3c9 Compare March 10, 2026 18:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/transloco/src/lib/tests/service/fallbacks.spec.ts`:
- Around line 141-163: The loader mock used by the test for the spec that calls
service.load('admin/notExists') must be made to throw for both scoped paths so
the error branch is exercised; update the loader's error list (used by the mock
referenced in this test) to include 'admin/notExists' and
'admin/fallbackNotExists' (in addition to the existing 'notExists',
'notExists2', 'fallbackNotExists'), so that createService(...) loading
'admin/notExists' with fallbackLang 'fallbackNotExists' triggers errors and
causes the catchError assertion to run when runLoader(2) is called.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 650ee9a1-7656-4926-a461-19c96af109e3

📥 Commits

Reviewing files that changed from the base of the PR and between 397b0d1 and 06bc3c9.

📒 Files selected for processing (1)
  • libs/transloco/src/lib/tests/service/fallbacks.spec.ts

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