date-fp
date-fp copied to clipboard
I18n
Add simple i18n support
@cullophid What about i18n support?
I think we could create a function called formatWithLocale()
which works exactly like format
but receives a locale object as first argument. Then, the format
function could just be a curried version of formatWithLocale
:
const format = formatWithLocale(DEFAULT_LOCALE)
With this approach, I could create formatters with any locale:
import { formatWithLocale } from 'date-fp'
// I can define my own locale
const LOCALE_PT_BR = {
MONTHS: ...,
WEEKDAYS: ...,
...
}
export const formatPtBr = formatWithLocale(LOCALE_PT_BR)
It would be nice to have some locales available in the package too:
import { formatWithLocale } from 'date-fp'
import LOCALE_PT_BR from 'date-fp/locales/pt-br'
export const formatPtBr = formatWithLocale(LOCALE_PT_BR)
@cullophid, what you think?
That sounds like a great idea! I would merge that PR ;)
IMO the library should stay as it is, or expand but leaving i18n outside of the movie as that can be handled by Intl.DateTimeFormat.