We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
you can create your formatter function which has to returns string as example:
formatter
<TimeAgo date={timeAgo} formatter={(value, unit) => { if (unit === 'second' && value < 15) return "just now"; if (unit === "second") return "few seconds ago"; if (unit === "minute") return `${value} ${value === 1 ? "minute" : "minutes"} ago`; ... }} />
How can I do this if I use localization?
import React from "react"; import TimeAgo from 'react-timeago'; import LocaleRU from 'react-timeago/lib/language-strings/ru'; import buildFormatter from 'react-timeago/lib/formatters/buildFormatter'; const formatter = buildFormatter(LocaleRU); import {Box} from '@material-ui/core'; export default ({date, title}) => { return( <Box component="small" color="text.disabled" fontWeight="bold"> <TimeAgo date={date} formatter={formatter} title={title} /> </Box> ); }
Originally posted by @mara1esh in #130 (comment)
The text was updated successfully, but these errors were encountered:
Since formatters are a functions you can wrap a localization function with your function to customize it however you need to.
Sorry, something went wrong.
I would be grateful if you could show a simple example, since I tried different options.
Same question. How can it be wrapped? I tried and couldn't get it working
No branches or pull requests
you can create your
formatter
function which has to returns stringas example:
How can I do this if I use localization?
Originally posted by @mara1esh in #130 (comment)
The text was updated successfully, but these errors were encountered: