ChristophP / elm-i18next

https://package.elm-lang.org/packages/ChristophP/elm-i18next/latest
BSD 3-Clause "New" or "Revised" License
67 stars 13 forks source link

Provide way of creating translations values without decoding JSON #21

Closed ChristophP closed 4 years ago

ChristophP commented 4 years ago
  1. Implement string : String -> Tree as an alias for Leaf
  2. Implement object : List (String, Tree) -> Tree using Branch
  3. Implement fromTree : List (String, Tree) -> Translations, using foldTree and Translations. I would expect a list as input here. If it were just a Tree someone could pass a string value as a root object, which couldn't be handled by t. That would make fromTree look like this:
    translations =
    I18Next.fromTree
      [ ("custom"
        , object
            [ ( "morning", string "Morning" )
            , ( "evening", string "Evening" )
            , ( "afternoon", string "Afternoon" )
            ]
        )
      , ("hello", string "hello")
     ]
  4. Expose Tree, string, object, fromTree and write a tests checking if t return the correct values when given a translations value that is custom built.

Would you want to give the implementation a try? I can also do it but it'll likely be sometime next week till I find time.

ChristophP commented 4 years ago

@Tehnix It's done and released. Hope this solves your use case.

Tehnix commented 4 years ago

@ChristophP thanks so much for setting time away for this, it solves it perfectly while also accommodating the more complex cases! :)

ChristophP commented 4 years ago

@Tehnix Sweet, glad it helps. :-)