Skip to content

Conversation

@shaharkazaz
Copy link
Collaborator

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:

What is the current behavior?

The ng-add schematic hardcodes the translation files path to assets/i18n/, which doesn't work properly with Angular 18+ projects that use the new public/ folder structure instead of src/assets/.

Issue Number: #818

What is the new behavior?

The ng-add schematic now automatically detects whether to use public/i18n/ or assets/i18n/ based on:

  1. Folder detection: Checks if /public or ${sourceRoot}/assets exists
  2. Version detection: Falls back to checking Angular version in package.json (18+ uses public/)
  3. User override: Respects explicit --path parameter if provided

This ensures translation files are placed in the correct location and the HTTP loader uses the right URL path for both modern and legacy Angular projects.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

The implementation maintains full backward compatibility while adding intelligent detection for Angular 18+ projects. All existing projects continue to work as before, while new Angular 18+ projects automatically get the correct public/ folder configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 3, 2025

Open in StackBlitz

@jsverse/transloco

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

@jsverse/transloco-locale

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

@jsverse/transloco-messageformat

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

@jsverse/transloco-optimize

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

@jsverse/transloco-persist-lang

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

@jsverse/transloco-persist-translations

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

@jsverse/transloco-preload-langs

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

@jsverse/transloco-schematics

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

@jsverse/transloco-scoped-libs

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

@jsverse/transloco-utils

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

@jsverse/transloco-validator

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

commit: 82ee48d

@shaharkazaz
Copy link
Collaborator Author

Verified on an Angular v16 and v18 project.

@shaharkazaz shaharkazaz merged commit 33b6df9 into master Oct 11, 2025
6 checks passed
@shaharkazaz shaharkazaz deleted the issue-818-ng-add branch October 11, 2025 12:55
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