-
-
Notifications
You must be signed in to change notification settings - Fork 211
Description
Is there an existing issue for this?
- I have searched the existing issues
Which Transloco package(s) are the source of the bug?
Transloco
Is this a regression?
No
Current behavior
When using translateSignal('some.key') or translateObjectSignal('some.key') without explicitly providing a scope, Transloco automatically fetches the scope from the dependency injection context (inject(TRANSLOCO_SCOPE)). If a scope (e.g., validation) is present in the DI context, it prepends this scope to the translation key, resulting in lookups like validation.some.key instead of just some.key. This is unexpected and can cause incorrect translations to be used, especially when the developer intends to use a root-level key.
Expected behavior
If no scope is provided to translateSignal or translateObjectSignal, Transloco should use the translation key as-is, without inferring or prepending any scope from the DI context. The behavior should be consistent with selectTranslate, which does not infer a scope unless one is explicitly provided.
Please provide a link to a minimal reproduction of the bug, if you won't provide a link the issue won't be handled.
https://codesandbox.io/p/devbox/quiet-snowflake-4zn2tf?workspaceId=ws_MMfF28NiXcF9q6oq2kP3fe
Transloco Config
Please provide the environment you discovered this bug in
Angular CLI: 18.2.11
Node: 22.14.0
Package Manager: yarn 4.9.1
OS: darwin x64
Angular: 18.2.9
Browser
Additional context
Please check the lazy component in Sandbox.
I would like to make a pull request for this bug
Yes 🚀