question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Howto Use interpolation format function with parameters?

See original GitHub issue

hey,

so we have a ton of already translated elements in the Intl Api but I really would like to move to i18next. Problem is some of those translation messages are using pretty specific Intl Apis. (e.g. intl-messageformat)

I though yeah no problem just provide interpolate format function… but I don’t have the parameters in the interpolation format function…

If I had I could just add a format for Intl like so right?

en:
  translations:
    key: "Hey {{there}}",
    keyWithIntl: "{{Hey {there}, Intl}}"

interpolation:
  format: function(value, format, language, parameters) { //parameters would be new
    if (format === 'Intl') {
      let intlObject= new IntlMessageFormat(value, language);
      return intlObject.format(parameters);
    }
  }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jamuhlcommented, Jan 27, 2020

@tonix-tuft had time today - landed in i18next@19.1.0 ->

interpolation:
  format: function(value, format, language, options) { } // newly added options as 4th argument
1reaction
tonix-tuftcommented, Jan 24, 2020

Will take a look, try it and let you know thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

string interpolation - format string output
Beginning with C# 10, you can use string interpolation to initialize a constant string. All expressions used for placeholders must be constant ...
Read more >
c# - Is it possible to pass interpolated strings as parameter ...
Another simple option is to pass just the format: MyMethod("00") and i. ToString(format) , but that only works in your presumably simplified example....
Read more >
String Interpolation in JavaScript
In JavaScript, the template string implements the string interpolation. A template string is defined by wrapping a sequence of characters into ...
Read more >
Python String Interpolation
%-format method is very old method for interpolation and is not recommended to use as it decrease the code readability. In str.format() method...
Read more >
Interpolation
If the interpolation functionality provided doesn't suit you, you can use ... in the init options or by passing additional options to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found