Skip to content
New issue

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

feat: Add i18n #10

Merged
merged 1 commit into from
May 16, 2021
Merged

feat: Add i18n #10

merged 1 commit into from
May 16, 2021

Conversation

PanagiotisGeorgiadis
Copy link
Owner

Implements #9

@mtellezj
Copy link

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
Copy link

iwtilma commented May 11, 2021

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

@PanagiotisGeorgiadis
Copy link
Owner Author

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
Copy link
Owner Author

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 😄

@PanagiotisGeorgiadis PanagiotisGeorgiadis merged commit 9b514a3 into master May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants