GithubHelp home page GithubHelp logo

I18n about date-fp HOT 4 OPEN

cullophid avatar cullophid commented on May 17, 2024
I18n

from date-fp.

Comments (4)

gsantiago avatar gsantiago commented on May 17, 2024 1

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?

from date-fp.

cullophid avatar cullophid commented on May 17, 2024 1

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

from date-fp.

gsantiago avatar gsantiago commented on May 17, 2024

@cullophid What about i18n support?

from date-fp.

mgtitimoli avatar mgtitimoli commented on May 17, 2024

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.

from date-fp.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.