UIBakery and i18n share interpolation delimiters

There is a conflict between UIBakery and i18next in how values are interpolated. Both use {{ }} per default as delimiters, so doing interpolation in i18n like the following wonโ€™t work out of the box:

i18n.init({
  resources: {
    en: {
      'key': 'This is a {{myVar}}',
      ...
    }
  }
});
i18n.t('key', {myVar: 'test!'});
// Expected result: 'This is a test!'
// Actual result: 'This is a myVar'

There is a easy way to make it work, though.
i18n options on initialization allow you to overwrite the prefix {{ and suffix }} with any characters:

i18next.init({
    interpolation: {
      prefix: '${'
    },
    resources: {
      en: {
        'key': 'Works like a ${thing}}'
      }
    }
});
i18n.t('key', {thing: 'charm!'});
// output: 'Works like a charm!'

So there is no need for support here, I just wanted to make UIBakery aware of this and maybe help some people who had issues making it work.

1 Like

Hi @Max, and thank you!
We will have a look :slight_smile:

1 Like