Skip to content

fix: preserve proper nouns in diagnostic reasons - #2018

Merged
eoinest merged 1 commit into
mainfrom
e/multi/preserve-diagnostic-proper-nouns
Aug 1, 2026
Merged

fix: preserve proper nouns in diagnostic reasons#2018
eoinest merged 1 commit into
mainfrom
e/multi/preserve-diagnostic-proper-nouns

Conversation

@eoinest

@eoinest eoinest commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve authored casing when diagnostic reasons are combined, so proper names such as Next.js are not lowercased.
  • Normalize existing sentence-fragment reasons and cover the actual gt-next warning while keeping prior diagnostic output unchanged.

Testing

  • pnpm build — passed (20 packages)
  • pnpm --filter generaltranslation test — passed (31 files, 499 tests)
  • pnpm --filter gt-next test:js — passed (25 files, 273 tests)
  • pnpm --filter @generaltranslation/react-core test — passed (11 files, 46 tests)
  • pnpm --filter gt-next exec vitest run src/errors/__tests__/createErrors.test.ts — passed (1 file, 3 tests)
  • pnpm exec oxlint <changed TypeScript files> — passed
  • pnpm exec oxfmt --check <changed files> — passed

Notes

Greptile Summary

This PR fixes a bug in createDiagnosticMessage where the lowercaseFirstWord helper was incorrectly downcasing proper nouns (e.g. Next.jsnext.js) when combining why clauses into a single sentence. The fix removes lowercaseFirstWord entirely and shifts the responsibility to each call site, which must now author why strings as sentence fragments using their intended in-sentence casing.

  • diagnostics.ts: Removes lowercaseFirstWord; why and wayOut clauses are now passed directly to stripSentence. The wayOut path is effectively a no-op change since shouldCombineWayOut already required wayOut to start with a lowercase letter via /^[a-z]/.
  • Call-site updates (client.ts, createErrors.ts, ssg.ts, singleton-operations.ts): Existing why clauses that started with common English words (This, The, Static, Without) are lowercased to match the new convention.
  • Tests: New cases in both diagnostics.test.ts and createErrors.test.ts verify that Next.js casing is preserved end-to-end, and that the createNextI18nConfigMismatchWarning helper produces the correct full message string.

Confidence Score: 5/5

Safe to merge — the change is narrow, well-tested, and all call sites have been updated to the new convention.

The removal of lowercaseFirstWord is clean: the why path is the only place producing wrong output, all affected call sites have been updated to lowercase-start fragments, and a grep across the monorepo confirms no remaining why clause would produce an awkward combined sentence. The wayOut removal is provably inert because shouldCombineWayOut already gates on the clause starting lowercase. New tests cover both the core utility and the specific createNextI18nConfigMismatchWarning entry point that triggered the issue.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
packages/core/src/logging/diagnostics.ts Removes lowercaseFirstWord helper and passes why/wayOut clauses directly to stripSentence; fixes proper-noun casing without behavioral regression for wayOut (already gated by a /^[a-z]/ check).
packages/next/src/errors/createErrors.ts Adds createNextI18nConfigMismatchWarning export with proper proper-noun casing; updates two why clauses to sentence-fragment form (lowercase start).
packages/next/src/errors/ssg.ts Two why clauses updated to lowercase sentence-fragment form, consistent with the new convention.
packages/next/src/errors/client.ts Single why clause lowercased to match new sentence-fragment convention.
packages/react-core/src/condition-store/singleton-operations.ts why clause lowercased to match new sentence-fragment convention.
packages/core/src/logging/tests/diagnostics.test.ts New test case verifies proper-noun casing is preserved in combined why clauses.
packages/next/src/errors/tests/createErrors.test.ts New test suite for createNextI18nConfigMismatchWarning validates the full message string including preserved Next.js casing.
.changeset/calm-geckos-smile.md Patch changeset for generaltranslation, @generaltranslation/react-core, and gt-next — appropriately scoped.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["createDiagnosticMessage(input)"] --> B{why provided?}
    B -- Yes --> C["stripSentence(whatHappened) + ' because ' + stripSentence(why)"]
    B -- No --> D["whatHappened as-is"]
    C --> E{fix AND wayOut AND wayOut starts with a-z?}
    D --> E
    E -- Yes --> F["stripSentence(fix) + ', or ' + stripSentence(wayOut)"]
    E -- No --> G["fix as-is"]
    F --> H["Assemble parts via ensureSentence and join"]
    G --> H
    H --> I["Add source/severity prefix"]
    I --> J["Final diagnostic string"]
Loading

Reviews (1): Last reviewed commit: "fix: preserve proper nouns in diagnostic..." | Re-trigger Greptile

@eoinest
eoinest enabled auto-merge (squash) August 1, 2026 00:37
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
generaltranslation 18.09 KB (-0.18% 🔽)
generaltranslation/runtime 14.87 KB (-0.45% 🔽)
generaltranslation/id 2.55 KB (0%)
generaltranslation/internal 7.36 KB (-0.41% 🔽)
generaltranslation/types 115 B (0%)
generaltranslation/errors 81 B (0%)
@generaltranslation/format 9.5 KB (0%)
@generaltranslation/format/types 89 B (0%)
@generaltranslation/format/internal 880 B (0%)
gt-i18n 11.88 KB (-0.23% 🔽)
gt-i18n/types 13 B (0%)
gt-i18n/internal 22.45 KB (-0.04% 🔽)
gt-i18n/internal/types 13 B (0%)
@generaltranslation/react-core/pure 25.52 KB (-0.18% 🔽)
@generaltranslation/react-core/hooks 20.59 KB (-0.09% 🔽)
@generaltranslation/react-core/components 22.67 KB (-0.58% 🔽)
@generaltranslation/react-core/components-rsc 26.15 KB (-0.05% 🔽)
gt-react (client) 31.99 KB (-0.09% 🔽)
gt-react (rsc) 28.63 KB (-0.04% 🔽)
gt-react (server) 31.62 KB (-0.16% 🔽)
gt-react/macros 8.81 KB (-0.4% 🔽)
gt-next (client) 43.83 KB (-0.16% 🔽)
gt-next (rsc) 47.77 KB (-0.3% 🔽)
gt-next (server) 44.11 KB (+0.23% 🔺)
gt-next/config 269.99 KB (-0.07% 🔽)
gt-next/server 46.4 KB (-0.01% 🔽)
gt-next/middleware 36.52 KB (-0.14% 🔽)
gt-next/link 42.88 KB (+0.28% 🔺)
gt-next/internal/_dictionary 144 B (0%)
gt-next/internal/_load-translations 144 B (0%)
gt-next/internal/_load-dictionary 144 B (0%)
gt-next/internal/_getLocale 125 B (0%)
gt-next/internal/_getRegion 122 B (0%)
gt-node 23.5 KB (-0.21% 🔽)
gt-node/types 219 B (0%)
gt-node/internal 13.45 KB (-0.16% 🔽)
gt-tanstack-start (client) 31.61 KB (-0.13% 🔽)
gt-tanstack-start (server) 32.03 KB (-0.22% 🔽)
gt-tanstack-start/server 10.24 KB (-0.28% 🔽)
gt-react-native 30.07 KB (+0.09% 🔺)
gt-react-native/plugin 4.6 KB (+0.15% 🔺)
gt-react-native/internal 746 B (0%)

@eoinest
eoinest merged commit 9b3eb92 into main Aug 1, 2026
31 checks passed
@eoinest
eoinest deleted the e/multi/preserve-diagnostic-proper-nouns branch August 1, 2026 00:44
@github-actions github-actions Bot mentioned this pull request Aug 1, 2026
eoinest pushed a commit that referenced this pull request Aug 5, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## gt@2.16.1

### Patch Changes

- [#2019](#2019)
[`60d154c`](60d154c)
Thanks [@eoinest](https://github.com/eoinest)! - Save local edits before
translation by default, with a `--no-save-local` flag to opt out.

- [#2028](#2028)
[`8066d0a`](8066d0a)
Thanks [@eoinest](https://github.com/eoinest)! - Stop the setup wizard
at monorepo workspace roots and direct users to run it from the app they
want to localize.

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - @generaltranslation/python-extractor@0.2.34
  - @generaltranslation/supported-locales@2.1.14
## @generaltranslation/compiler@1.3.36

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
## generaltranslation@9.1.1

### Patch Changes

- [#2018](#2018)
[`9b3eb92`](9b3eb92)
Thanks [@eoinest](https://github.com/eoinest)! - Preserve proper-noun
casing when diagnostic reasons are combined into user-facing messages.
## gtx-cli@2.16.1

### Patch Changes

- Updated dependencies
[[`60d154c`](60d154c),
[`8066d0a`](8066d0a)]:
  - gt@2.16.1
## gt-i18n@1.0.11

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
## locadex@1.0.204

### Patch Changes

- Updated dependencies
[[`60d154c`](60d154c),
[`8066d0a`](8066d0a)]:
  - gt@2.16.1
## gt-next@11.1.5

### Patch Changes

- [#2018](#2018)
[`9b3eb92`](9b3eb92)
Thanks [@eoinest](https://github.com/eoinest)! - Preserve proper-noun
casing when diagnostic reasons are combined into user-facing messages.

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - @generaltranslation/react-core@11.1.5
  - @generaltranslation/compiler@1.3.36
  - gt-i18n@1.0.11
  - gt-react@11.1.5
## gt-node@1.0.12

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - gt-i18n@1.0.11
## @generaltranslation/python-extractor@0.2.34

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
## gt-react@11.1.5

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - @generaltranslation/react-core@11.1.5
  - gt-i18n@1.0.11
## @generaltranslation/react-core@11.1.5

### Patch Changes

- [#2018](#2018)
[`9b3eb92`](9b3eb92)
Thanks [@eoinest](https://github.com/eoinest)! - Preserve proper-noun
casing when diagnostic reasons are combined into user-facing messages.

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - gt-i18n@1.0.11
## gt-react-native@11.1.5

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - @generaltranslation/react-core@11.1.5
  - gt-i18n@1.0.11
  - @generaltranslation/supported-locales@2.1.14
## gt-sanity@3.1.3

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
## @generaltranslation/supported-locales@2.1.14

### Patch Changes

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
## gt-tanstack-start@11.1.5

### Patch Changes

- [#2010](#2010)
[`8436d54`](8436d54)
Thanks [@eoinest](https://github.com/eoinest)! - Export `gtMiddleware`
from the browser condition so TanStack Start client builds can evaluate
application setup files that register it.

- Updated dependencies
[[`9b3eb92`](9b3eb92)]:
  - generaltranslation@9.1.1
  - @generaltranslation/react-core@11.1.5
  - gt-i18n@1.0.11
  - gt-react@11.1.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Diagnostic why clause lowercases proper nouns: "because next.js may select a locale"

2 participants