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
ericb97 opened this issue Jan 4, 2022 · 3 comments
Closed

Comments

@ericb97
Copy link

@ericb97 ericb97 commented Jan 4, 2022

馃悰 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
@ericb97 ericb97 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
Copy link
Member

@adrai adrai commented Jan 4, 2022

should be fixed with v21.6.5

@ericb97
Copy link
Author

@ericb97 ericb97 commented Jan 4, 2022

Thanks for the very fast fix!

@adrai
Copy link
Member

@adrai 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