aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/Translations.elm
diff options
context:
space:
mode:
authorJoris2015-12-29 22:38:42 +0100
committerJoris2015-12-29 22:38:42 +0100
commita7db22556b91bc7c499e010b4c051f4442ad8ce2 (patch)
tree9f991523cee681bf179c191260b95672f1c44def /src/client/Model/Translations.elm
parentc79fa3e212e8bb49f950da3c3218e32e3b9df2ec (diff)
downloadbudget-a7db22556b91bc7c499e010b4c051f4442ad8ce2.tar.gz
budget-a7db22556b91bc7c499e010b4c051f4442ad8ce2.tar.bz2
budget-a7db22556b91bc7c499e010b4c051f4442ad8ce2.zip
Using persona to validate emails
Diffstat (limited to 'src/client/Model/Translations.elm')
-rw-r--r--src/client/Model/Translations.elm69
1 files changed, 0 insertions, 69 deletions
diff --git a/src/client/Model/Translations.elm b/src/client/Model/Translations.elm
deleted file mode 100644
index bec8c9b..0000000
--- a/src/client/Model/Translations.elm
+++ /dev/null
@@ -1,69 +0,0 @@
-module Model.Translations
- ( translationsDecoder
- , Translations
- , Translation
- , getMessage
- , getParamMessage
- ) where
-
-import Maybe exposing (withDefault)
-import Json.Decode as Json exposing ((:=))
-import String
-
-type alias Translations = List Translation
-
-translationsDecoder : Json.Decoder Translations
-translationsDecoder = Json.list translationDecoder
-
-type alias Translation =
- { key : String
- , message : List MessagePart
- }
-
-getTranslation : String -> Translations -> Maybe (List MessagePart)
-getTranslation key translations =
- translations
- |> List.filter (\translation -> translation.key == key)
- |> List.head
- |> Maybe.map .message
-
-translationDecoder : Json.Decoder Translation
-translationDecoder =
- Json.object2 Translation
- ("key" := Json.string)
- ("message" := Json.list partDecoder)
-
-type MessagePart =
- Order Int
- | Str String
-
-partDecoder : Json.Decoder MessagePart
-partDecoder =
- ("tag" := Json.string) `Json.andThen` partDecoderWithTag
-
-partDecoderWithTag : String -> Json.Decoder MessagePart
-partDecoderWithTag tag =
- case tag of
- "Order" -> Json.object1 Order ("contents" := Json.int)
- "Str" -> Json.object1 Str ("contents" := Json.string)
-
------
-
-getMessage : String -> Translations -> String
-getMessage = getParamMessage []
-
-getParamMessage : List String -> String -> Translations -> String
-getParamMessage values key translations =
- getTranslation key translations
- |> Maybe.map (\parts -> String.concat (List.map (replacePart values) parts))
- |> withDefault key
-
-replacePart : List String -> MessagePart -> String
-replacePart values part =
- case part of
- Str str -> str
- Order n ->
- values
- |> List.drop (n - 1)
- |> List.head
- |> withDefault ("{" ++ (toString n) ++ "}")