Howto Use interpolation format function with parameters?
See original GitHub issuehey,
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:
- Created 6 years ago
- Comments:13 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tonix-tuft had time today - landed in i18next@19.1.0 ->
Will take a look, try it and let you know thanks!