aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model/Translations.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Model/Translations.elm')
-rw-r--r--src/client/elm/Model/Translations.elm25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/client/elm/Model/Translations.elm b/src/client/elm/Model/Translations.elm
index 57409b0..9b314e1 100644
--- a/src/client/elm/Model/Translations.elm
+++ b/src/client/elm/Model/Translations.elm
@@ -7,13 +7,13 @@ module Model.Translations exposing
)
import Maybe exposing (withDefault)
-import Json.Decode as Json exposing ((:=))
+import Json.Decode as Decode exposing (Decoder)
import String
type alias Translations = List Translation
-translationsDecoder : Json.Decoder Translations
-translationsDecoder = Json.list translationDecoder
+translationsDecoder : Decoder Translations
+translationsDecoder = Decode.list translationDecoder
type alias Translation =
{ key : String
@@ -27,25 +27,24 @@ getTranslation key translations =
|> List.head
|> Maybe.map .message
-translationDecoder : Json.Decoder Translation
+translationDecoder : Decoder Translation
translationDecoder =
- Json.object2 Translation
- ("key" := Json.string)
- ("message" := Json.list partDecoder)
+ Decode.map2 Translation
+ (Decode.field "key" Decode.string)
+ (Decode.field "message" (Decode.list partDecoder))
type MessagePart =
Order Int
| Str String
-partDecoder : Json.Decoder MessagePart
-partDecoder =
- ("tag" := Json.string) `Json.andThen` partDecoderWithTag
+partDecoder : Decoder MessagePart
+partDecoder = (Decode.field "tag" Decode.string) |> Decode.andThen partDecoderWithTag
-partDecoderWithTag : String -> Json.Decoder MessagePart
+partDecoderWithTag : String -> Decoder MessagePart
partDecoderWithTag tag =
case tag of
- "Order" -> Json.object1 Order ("contents" := Json.int)
- _ -> Json.object1 Str ("contents" := Json.string)
+ "Order" -> Decode.map Order (Decode.field "contents" Decode.int)
+ _ -> Decode.map Str (Decode.field "contents" Decode.string)
-----