Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passed format parameter value is truncated in options argument of custom formatter #1715

Closed
eric-boot opened this issue Jan 4, 2022 · 3 comments

Comments

@eric-boot
Copy link

馃悰 Bug Report

When using a custom formatter, any passed parameter value with a colon in it is not fully passed to the formatter, but truncated at the colon.

To Reproduce

See codesandbox.

Expected behavior

A colon in a parameter value should be passed along with the value after the colon.

i18next.init({
  lng: "en",
  resources: {
    en: {
      translation: {
        key: "Before {{date, customdate(format: EEEE d MMMM yyyy HH:mm; otherParam: 0)}}",
      }
    }
  }
});

i18next.services.formatter.add("customdate", (value, lng, options) => {
  return `customized date in format ${options.format} (and other param ${options.otherParam})`;
});

const now = new Date();
document.getElementById("app").innerHTML = i18next.t("key", { date: now });
// Before customized date in format EEEE d MMMM yyyy HH:mm (and other param 0)

Your Environment

  • runtime version: node v14.16.0
  • i18next version: 21.6.4
  • os: Linux
@eric-boot eric-boot changed the title Passed format parameter value is truncated in options argument passed to custom formatter Passed format parameter value is truncated in options argument of custom formatter Jan 4, 2022
@adrai adrai closed this as completed in ef13e2e Jan 4, 2022
@adrai
Copy link
Member

adrai commented Jan 4, 2022

should be fixed with v21.6.5

@eric-boot
Copy link
Author

Thanks for the very fast fix!

@adrai
Copy link
Member

adrai commented Jan 4, 2022

If you like this module don鈥檛 forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project.

There are many ways to help this project 馃檹

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

No branches or pull requests

2 participants