Support formatting in Interpolate component
See original GitHub issueCould you please add support for i18next formatting in Interpolate component?
Initial settings:
import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';
import moment from 'moment';
i18n.use(XHR)
.init({
fallbackLng: 'en',
ns: ['common'],
defaultNS: 'common',
debug: true,
interpolation: {
format: function(value, format, lng) {
if(value instanceof Date) return moment(value).format(format);
return value;
}
}
});
common.json:
{
"copyright":"© {{date, YYYY}}. {{link}} - All rights reserved"
}
and component:
<Interpolate i18nKey="copyright" useDangerouslySetInnerHTML date={new Date()} link={<a href="http://company" target="blank">Company</a>}/>
result is warning:
i18next: interpolator: missed to pass in variable date, YYYY for interpolating © {{date,YYYY}}. {{link}} - All rights reserved
Thank you
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (9 by maintainers)
Top Results From Across the Web
string interpolation - format string output
A format string that is supported by the type of the expression result. For more information, see Format String Component. The following example ......
Read more >Internationalization in React: Interpolation, Formatting and ...
In this blog, we will explore further on this aspect to include additional dynamicity and extra formatting to specific data types. Trans ...
Read more >Interpolate (v9) - react-i18next documentation
The interpolate component enables you to interpolate react components into translation strings (eg. to use links). ... You can use formatting as in...
Read more >Aligning strings within string.Format and interpolated strings
You can use alignment components in your format strings to both right-align and left-align your formatted values. This pads the formatted values ...
Read more >Components | Format.JS
The components render React elements by building on React Intl's imperative API. ... Support rich-text string/message formatting in <FormattedMessage> .
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

the links are over a year old…the new samples have no use of the Interpolate anylonger…as more or less that component is replaced by Trans component: https://react.i18next.com/components/trans-component.html
That I have changed while pasting the code in forum, Issue is not with this. My problem is format function is not excecuting.
On Thu, 28 Feb 2019 at 5:58 PM, Jan Mühlemann notifications@github.com wrote: