PanagiotisGeorgiadis / Elm-DatePicker

A DatePicker package created using Elm 0.19
https://package.elm-lang.org/packages/PanagiotisGeorgiadis/elm-datepicker/latest/
BSD 3-Clause "New" or "Revised" License
11 stars 2 forks source link

feat: Add i18n #10

Closed PanagiotisGeorgiadis closed 3 years ago

PanagiotisGeorgiadis commented 3 years ago

Implements #9

mtellezj commented 3 years ago

Hi @PanagiotisGeorgiadis, it looks very good. What about include some default locales?, something like:

module DatePicker.I18n.Es exposing (spanishI18n)

spanishI18n : I18n
spanishI18n =
    { monthToString = monthToString
    , weekdayToString = weekdayToString
    , todayButtonText = "Hoy"
    }

monthToString : TextMode -> Month -> String
monthToString mode month =
    let
        monthString =
            case month of
                 Jan ->
                     "Enero"
                 Feb ->
                      "Febrero"
                 ...
                 Dec ->
                       "Diciembre"
    in
    case mode of
        Condensed ->
            String.left 3 monthString
        Full ->
            monthString

If there is no predefined locale the user still can define monthToString, weekdayToString, todayButtonText. I'll be very glad to do the spanish module.

iwtilma commented 3 years ago

Hi @PanagiotisGeorgiadis Thank you very much for this! I can't wait to use it.

PanagiotisGeorgiadis commented 3 years ago

Hi @PanagiotisGeorgiadis, it looks very good. What about include some default locales?, something like:

module DatePicker.I18n.Es exposing (spanishI18n)

spanishI18n : I18n
spanishI18n =
    { monthToString = monthToString
    , weekdayToString = weekdayToString
    , todayButtonText = "Hoy"
    }

monthToString : TextMode -> Month -> String
monthToString mode month =
    let
        monthString =
            case month of
                 Jan ->
                     "Enero"
                 Feb ->
                      "Febrero"
                 ...
                 Dec ->
                       "Diciembre"
    in
    case mode of
        Condensed ->
            String.left 3 monthString
        Full ->
            monthString

If there is no predefined locale the user still can define monthToString, weekdayToString, todayButtonText. I'll be very glad to do the spanish module.

Hello @mtellezj, I've given this some thought and I think that by adding presets to the DatePicker package we'll be duplicating the i18n functionality along with having to release new versions for new languages.

I believe that its better to delegate it to the consumer and let them decide on how they want to display them. Also in some of the cases / languages it may make more sense for them to provide Months / Weekdays in caps so they'll need to override the defaults.

PanagiotisGeorgiadis commented 3 years ago

I'll merge this PR and bump the version and update the examples repo so hopefully from tomorrow everyone will be able to use i18n 😄