Skip to content

Bug(scope): Conflict in interpolation between DefaultTranspiler and MessageFormatTranspiler when using {}#900

Description

@sdo-1A

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) are the source of the bug?

Transloco, MessageFormat

Is this a regression?

No

Current behavior

I am currently migrating a project to @jsverse/transloco and I am facing the following issue:

Some of our localization files include translations within translations in addition to MessageFormat use cases which both use the same interpolation characters ({ }) so we updated the provideTransloco config with the following parameter: interpolation: ['{', '}'],

When calling the transloco pipe in our components, the MessageFormatTranspiler calls the default transpiler before compiling MessageFormat, which causes issues when MessageFormat patterns are processed as regular interpolation placeholders (it attempts to interpolate the MessageFormat patterns as translation keys and since these are not found in the translations, it returns an empty string).

Could you explain a potential workaround to fix this use case? Or a potential fix to the MessageFormatCompiler?

Expected behavior

We expect the translations to be updated and if not found then passed to the MessageFormat compiler

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/sandbox/jsverse-transloco-kn52hs

Transloco Config

provideTransloco({
      config: {
        ...
        interpolation: ['{', '}'],
      }
    }),
    provideTranslocoMessageformat()

Please provide the environment you discovered this bug in

Transloco: ~8.0.0
Angular: ~20.3.0
Node: >=22.11.0
Package Manager: yarn
OS:

Browser

Additional context

As you can see in the code sandbox preview, when changing the config to interpolation: ["{", "}"] in the app.config.ts, the examples on the Transpilers page no longer work.

I would like to make a pull request for this bug

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions