date-fp icon indicating copy to clipboard operation
date-fp copied to clipboard

I18n

Open cullophid opened this issue 8 years ago • 4 comments

Add simple i18n support

cullophid avatar Mar 26 '16 11:03 cullophid

@cullophid What about i18n support?

gsantiago avatar Nov 13 '17 13:11 gsantiago

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?

gsantiago avatar Nov 13 '17 13:11 gsantiago

That sounds like a great idea! I would merge that PR ;)

cullophid avatar Nov 14 '17 06:11 cullophid

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.

mgtitimoli avatar Jun 24 '18 20:06 mgtitimoli