Skip to content

Brackets breaking nesting interpolation #2336

@buxxi

Description

@buxxi

🐛 Bug Report

When using nesting and passing values down that contains brackets "(" or ")" the output gets mangled.

To Reproduce

import i18next from 'i18next';

async function initI18n() {
    await i18next.init({
        lng: 'en',
        resources: {
            en: {
                translation: {
                    first: '$t(second, {"name": "foo (bar)"})',
                    second: 'Hello {{name}}!'
                }
            }
        }
    });
    console.log(i18next.t('first'));
}

initI18n();

Expected behavior

I expect this to print:

Hello foo (bar)

But it prints:

Hello {{name}}!"})

Removing the brackets makes it print the expected value.

Your Environment

  • runtime version: node v20.11.1
  • i18next version: 25.3.2
  • os: Linux Pop!_OS 22.04

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