From 40431c8798e0e1d2b8684493b7b851f49ab8e21c Mon Sep 17 00:00:00 2001 From: Frank Schmitt Date: Sun, 19 Mar 2017 19:54:08 +0100 Subject: [PATCH 1/3] fixed typo (referencing wrong config) in Config tests --- tests/Date/Extra/ConfigTests.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Date/Extra/ConfigTests.elm b/tests/Date/Extra/ConfigTests.elm index 6d675f2..19407cb 100644 --- a/tests/Date/Extra/ConfigTests.elm +++ b/tests/Date/Extra/ConfigTests.elm @@ -6,7 +6,7 @@ import Expect import Date.Extra.Config.Config_en_au as Config_en_au import Date.Extra.Config.Config_en_us as Config_en_us -import Date.Extra.Config.Config_fr_fr as Config_en_gb +import Date.Extra.Config.Config_en_gb as Config_en_gb import Date.Extra.Config.Config_fr_fr as Config_fr_fr import Date.Extra.Config.Config_fi_fi as Config_fi_fi import Date.Extra.Config.Config_pl_pl as Config_pl_pl From c0c6c5775a704eae629bb3ef0e3d67d652da83e0 Mon Sep 17 00:00:00 2001 From: Frank Schmitt Date: Sun, 19 Mar 2017 23:08:14 +0100 Subject: [PATCH 2/3] German translation (tests still missing) --- src/Date/Extra/Config/Config_de_de.elm | 44 ++++++++++++++ src/Date/Extra/Config/Configs.elm | 2 + src/Date/Extra/I18n/I_de_de.elm | 84 ++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 src/Date/Extra/Config/Config_de_de.elm create mode 100644 src/Date/Extra/I18n/I_de_de.elm diff --git a/src/Date/Extra/Config/Config_de_de.elm b/src/Date/Extra/Config/Config_de_de.elm new file mode 100644 index 0000000..01176cd --- /dev/null +++ b/src/Date/Extra/Config/Config_de_de.elm @@ -0,0 +1,44 @@ +module Date.Extra.Config.Config_de_de exposing (..) + +{-| This is the default German config for formatting dates. + +@docs config + +Copyright (c) 2017 Frank Schmitt +-} + +import Date +import Date.Extra.Config as Config +import Date.Extra.I18n.I_de_de as German + + +{-| Config for en-us. +-} +config : Config.Config +config = + { i18n = + { dayShort = German.dayShort + , dayName = German.dayName + , monthShort = German.monthShort + , monthName = German.monthName + , dayOfMonthWithSuffix = German.dayOfMonthWithSuffix + } + , format = + { date = + "%-d. %b %Y. a" + -- d. M YYYY. a + , longDate = + "%A, %-d. %B %Y" + -- dddd, dd. MMMM yyyy + , time = + "%-H:%M" + -- h:mm + , longTime = + "%-H:%M:%S" + -- h:mm:ss + , dateTime = + "%a, %-d. %b %Y. %-H:%M:%S" + -- date + time + , firstDayOfWeek = Date.Mon + } + } diff --git a/src/Date/Extra/Config/Configs.elm b/src/Date/Extra/Config/Configs.elm index f23fb4f..1c4e64b 100644 --- a/src/Date/Extra/Config/Configs.elm +++ b/src/Date/Extra/Config/Configs.elm @@ -27,6 +27,7 @@ import Date.Extra.Config.Config_nl_nl as Config_nl_nl import Date.Extra.Config.Config_pt_br as Config_pt_br import Date.Extra.Config.Config_et_ee as Config_et_ee import Date.Extra.Config.Config_ja_jp as Config_ja_jp +import Date.Extra.Config.Config_de_de as Config_de_de {-| Built in configurations. -} @@ -44,6 +45,7 @@ configs = , ("pt_br", Config_pt_br.config) , ("et_ee", Config_et_ee.config) , ("ja_jp", Config_ja_jp.config) + , ("de_de", Config_de_de.config) ] diff --git a/src/Date/Extra/I18n/I_de_de.elm b/src/Date/Extra/I18n/I_de_de.elm new file mode 100644 index 0000000..e552f98 --- /dev/null +++ b/src/Date/Extra/I18n/I_de_de.elm @@ -0,0 +1,84 @@ +module Date.Extra.I18n.I_de_de exposing (..) + +{-| German values for day and month names. + +@docs dayShort +@docs dayName +@docs monthShort +@docs monthName +@docs dayOfMonthWithSuffix + +Copyright (c) 2017 Frank Schmitt +-} + + +import Date exposing (Day (..), Month (..)) +import String exposing (padLeft) + + +{-| Day short name. -} +dayShort : Day -> String +dayShort day = + case day of + Mon -> "Mo" + Tue -> "Di" + Wed -> "Mi" + Thu -> "Do" + Fri -> "Fr" + Sat -> "Sa" + Sun -> "So" + + +{-| Day full name. -} +dayName : Day -> String +dayName day = + case day of + Mon -> "Montag" + Tue -> "Dienstag" + Wed -> "Mittwoch" + Thu -> "Donnerstag" + Fri -> "Freitag" + Sat -> "Samstag" + Sun -> "Sonntag" + + +{-| Month short name. -} +monthShort : Month -> String +monthShort month = + case month of + Jan -> "Jan" + Feb -> "Feb" + Mar -> "Mär" + Apr -> "Apr" + May -> "Mai" + Jun -> "Jun" + Jul -> "Jul" + Aug -> "Aug" + Sep -> "Sep" + Oct -> "Okt" + Nov -> "Nov" + Dec -> "Dez" + + +{-| Month full name. -} +monthName : Month -> String +monthName month = + case month of + Jan -> "Januar" + Feb -> "Februar" + Mar -> "März" + Apr -> "April" + May -> "Mai" + Jun -> "Juni" + Jul -> "Juli" + Aug -> "August" + Sep -> "September" + Oct -> "Oktober" + Nov -> "November" + Dec -> "Dezember" + + +{-| Nothing to do here for German -} +dayOfMonthWithSuffix : Bool -> Int -> String +dayOfMonthWithSuffix pad day = + (toString day) ++ "." From 70dacb7c9c7b34a2ba45178f12dc556851f696d7 Mon Sep 17 00:00:00 2001 From: Frank Schmitt Date: Thu, 23 Mar 2017 22:48:55 +0100 Subject: [PATCH 3/3] German translation: added tests, fixed date format --- src/Date/Extra/Config/Config_de_de.elm | 2 +- tests/Date/Extra/ConfigTests.elm | 7 +++++++ tests/Date/Extra/FormatTests.elm | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Date/Extra/Config/Config_de_de.elm b/src/Date/Extra/Config/Config_de_de.elm index 01176cd..ffd405d 100644 --- a/src/Date/Extra/Config/Config_de_de.elm +++ b/src/Date/Extra/Config/Config_de_de.elm @@ -25,7 +25,7 @@ config = } , format = { date = - "%-d. %b %Y. a" + "%-d. %B %Y" -- d. M YYYY. a , longDate = "%A, %-d. %B %Y" diff --git a/tests/Date/Extra/ConfigTests.elm b/tests/Date/Extra/ConfigTests.elm index 6d675f2..f0405bd 100644 --- a/tests/Date/Extra/ConfigTests.elm +++ b/tests/Date/Extra/ConfigTests.elm @@ -15,6 +15,7 @@ import Date.Extra.Config.Config_nl_nl as Config_nl_nl import Date.Extra.Config.Config_pt_br as Config_pt_br import Date.Extra.Config.Config_et_ee as Config_et_ee import Date.Extra.Config.Config_ja_jp as Config_ja_jp +import Date.Extra.Config.Config_de_de as Config_de_de import Date.Extra.Config.Configs as Configs @@ -29,6 +30,7 @@ config_nl_nl = Config_nl_nl.config config_pt_br = Config_pt_br.config config_et_ee = Config_et_ee.config config_ja_jp = Config_ja_jp.config +config_de_de = Config_de_de.config tests : Test @@ -99,4 +101,9 @@ tests = Expect.equal config_ja_jp.format (Configs.getConfig "ja_jp").format + , test "getConfig de_de" <| + \() -> + Expect.equal + config_de_de.format + (Configs.getConfig "de_de").format ] diff --git a/tests/Date/Extra/FormatTests.elm b/tests/Date/Extra/FormatTests.elm index 2c29614..29d1bb1 100644 --- a/tests/Date/Extra/FormatTests.elm +++ b/tests/Date/Extra/FormatTests.elm @@ -24,6 +24,7 @@ import Date.Extra.Config.Config_nl_nl as Config_nl_nl import Date.Extra.Config.Config_pt_br as Config_pt_br import Date.Extra.Config.Config_et_ee as Config_et_ee import Date.Extra.Config.Config_ja_jp as Config_ja_jp +import Date.Extra.Config.Config_de_de as Config_de_de import Date.Extra.Period as DPeriod exposing (Period (Hour)) @@ -38,6 +39,7 @@ config_nl_nl = Config_nl_nl.config config_pt_br = Config_pt_br.config config_et_ee = Config_et_ee.config config_ja_jp = Config_ja_jp.config +config_de_de = Config_de_de.config tests : Test @@ -185,6 +187,8 @@ formatConfigTestCases = , ("Config_et_ee format idiom", "teisipäev (5.) 05 august 2014", config_et_ee, dayDayIdiomMonth, aTestTime5) , ("Config_ja_jp day idiom", "2014/8/5", config_ja_jp, config_ja_jp.format.date, aTestTime5) , ("Config_ja_jp format idiom", "火曜日 (5) 05 8月 2014", config_ja_jp, dayDayIdiomMonth, aTestTime5) + , ("Config_de_de date idiom", "5. August 2014", config_de_de, config_de_de.format.date, aTestTime5) + , ("Config_de_de longDate idiom", "Dienstag, 5. August 2014", config_de_de, config_de_de.format.longDate, aTestTime5) ]