Skip to content

Commit

Permalink
Merge pull request #41 from relabsoss/ru_de_locale
Browse files Browse the repository at this point in the history
Ru de locale
  • Loading branch information
rluiten authored Mar 31, 2017
2 parents 998a9d5 + 17b296d commit 9f906cb
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
2 changes: 2 additions & 0 deletions elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"Date.Extra.I18n.I_pt_br",
"Date.Extra.I18n.I_et_ee",
"Date.Extra.I18n.I_ja_jp",
"Date.Extra.I18n.I_ru_ru",
"Date.Extra.Config.Configs",
"Date.Extra.Config.Config_en_au",
"Date.Extra.Config.Config_en_us",
Expand All @@ -37,6 +38,7 @@
"Date.Extra.Config.Config_pt_br",
"Date.Extra.Config.Config_et_ee",
"Date.Extra.Config.Config_ja_jp",
"Date.Extra.Config.Config_ru_ru",
"Date.Extra.Field"
],
"dependencies": {
Expand Down
33 changes: 33 additions & 0 deletions src/Date/Extra/Config/Config_ru_ru.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Date.Extra.Config.Config_ru_ru exposing (..)

{-| This is the default russian config for formatting dates.
@docs config
Copyright (c) 2016 Slava Turchaninov
-}

import Date
import Date.Extra.Config as Config
import Date.Extra.I18n.I_ru_ru as Russian


{-| Config for ru-ru. -}
config : Config.Config
config =
{ i18n =
{ dayShort = Russian.dayShort
, dayName = Russian.dayName
, monthShort = Russian.monthShort
, monthName = Russian.monthName
, dayOfMonthWithSuffix = Russian.dayOfMonthWithSuffix
}
, format =
{ date = "%d/%m/%Y" -- d/M/YYY
, longDate = "%A, %B %d, %Y" -- dddd, MMMM dd, yyyy
, time = "%H:%M" -- H:mm tt
, longTime = "%H:%M:%S" -- H:mm:ss
, dateTime = "%d/%m/%Y %H:%M" -- date + time
, firstDayOfWeek = Date.Mon
}
}
2 changes: 2 additions & 0 deletions src/Date/Extra/Config/Configs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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_ru_ru as Config_ru_ru
import Date.Extra.Config.Config_de_de as Config_de_de


Expand All @@ -45,6 +46,7 @@ configs =
, ("pt_br", Config_pt_br.config)
, ("et_ee", Config_et_ee.config)
, ("ja_jp", Config_ja_jp.config)
, ("ru_ru", Config_ru_ru.config)
, ("de_de", Config_de_de.config)
]

Expand Down
85 changes: 85 additions & 0 deletions src/Date/Extra/I18n/I_ru_ru.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
module Date.Extra.I18n.I_ru_ru exposing (..)

{-| Russian values for day and month names.
@docs dayShort
@docs dayName
@docs monthShort
@docs monthName
@docs dayOfMonthWithSuffix
Copyright (c) 2017 Slava Turchaninov
-}


import Date exposing (Day (..), Month (..))
import String exposing (padLeft)


{-| Day short name. -}
dayShort : Day -> String
dayShort day =
case day of
Mon -> "Пн"
Tue -> "Вт"
Wed -> "Ср"
Thu -> "Чт"
Fri -> "Пт"
Sat -> "Сб"
Sun -> "Вс"


{-| Day full name. -}
dayName : Day -> String
dayName day =
case day of
Mon -> "Понедельник"
Tue -> "Вторник"
Wed -> "Среда"
Thu -> "Четверг"
Fri -> "Пятница"
Sat -> "Суббота"
Sun -> "Воскресенье"


{-| Month short name. -}
monthShort : Month -> String
monthShort month =
case month of
Jan -> "Янв"
Feb -> "Фев"
Mar -> "Мар"
Apr -> "Апр"
May -> "Май"
Jun -> "Июн"
Jul -> "Июл"
Aug -> "Авг"
Sep -> "Сен"
Oct -> "Окт"
Nov -> "Ноя"
Dec -> "Дек"


{-| Month full name. -}
monthName : Month -> String
monthName month =
case month of
Jan -> "Январь"
Feb -> "Февраль"
Mar -> "Март"
Apr -> "Апрель"
May -> "Май"
Jun -> "Июнь"
Jul -> "Июль"
Aug -> "Август"
Sep -> "Сентябрь"
Oct -> "Октябрь"
Nov -> "Ноябрь"
Dec -> "Декабрь"


{-| Just convert to string-}
dayOfMonthWithSuffix : Bool -> Int -> String
dayOfMonthWithSuffix pad day =
case day of
_ -> (toString day)
7 changes: 7 additions & 0 deletions tests/Date/Extra/ConfigTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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_ru_ru as Config_ru_ru
import Date.Extra.Config.Config_de_de as Config_de_de
import Date.Extra.Config.Configs as Configs

Expand All @@ -30,6 +31,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_ru_ru = Config_ru_ru.config
config_de_de = Config_de_de.config


Expand Down Expand Up @@ -101,6 +103,11 @@ tests =
Expect.equal
config_ja_jp.format
(Configs.getConfig "ja_jp").format
, test "getConfig ru_ru" <|
\() ->
Expect.equal
config_ru_ru.format
(Configs.getConfig "ru_ru").format
, test "getConfig de_de" <|
\() ->
Expect.equal
Expand Down
5 changes: 5 additions & 0 deletions tests/Date/Extra/FormatTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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_ru_ru as Config_ru_ru
import Date.Extra.Config.Config_de_de as Config_de_de
import Date.Extra.Period as DPeriod exposing (Period (Hour))

Expand All @@ -39,6 +40,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_ru_ru = Config_ru_ru.config
config_de_de = Config_de_de.config


Expand Down Expand Up @@ -187,6 +189,9 @@ 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_ru_ru day idiom", "05/08/2014", config_ru_ru, config_ru_ru.format.date, aTestTime5)
, ("Config_ru_ru format idiom", "Вторник (5) 05 Август 2014", config_ru_ru, dayDayIdiomMonth, aTestTime5)
, ("Config_ru_ru time idiom", "05:53", config_ru_ru, config_ru_ru.format.time, 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)
]
Expand Down

0 comments on commit 9f906cb

Please sign in to comment.