Skip to content

Commit

Permalink
Merge pull request #10 from ChristophP/adjust-tests-and-docs-for-19
Browse files Browse the repository at this point in the history
Adjust tests and docs for 19
  • Loading branch information
ChristophP authored Nov 11, 2018
2 parents a0fa6fa + e4f749e commit 30491e0
Show file tree
Hide file tree
Showing 13 changed files with 2,436 additions and 2,224 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ you can just use the decoder on it and put it into the Model.
In JS do:
```js
// translations is a JSON string or JS object
Elm.YourApp.embed(someDomNode, translations);
Elm.Main.init({ flags: translations });
```
Then in elm, you use them in the init function of your app:
```elm
Expand Down
30 changes: 0 additions & 30 deletions Translations.elm

This file was deleted.

8 changes: 5 additions & 3 deletions elm.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"type": "package",
"name": "ChristophP/elm-i18next",
"summary": "Use this module to load, decode and use translations in your app",
"summary": "A module to load, decode and use translations in your app",
"license": "BSD-3-Clause",
"version": "3.0.1",
"version": "3.0.2",
"exposed-modules": [
"I18Next"
],
Expand All @@ -13,5 +13,7 @@
"elm/http": "1.0.0 <= v < 2.0.0",
"elm/json": "1.0.0 <= v < 2.0.0"
},
"test-dependencies": {}
"test-dependencies": {
"elm-explorations/test": "1.1.0 <= v < 2.0.0"
}
}
41 changes: 22 additions & 19 deletions examples/Regular.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Main exposing (..)
module Main exposing (Model, Msg(..), init, main, update, view)

import Html exposing (button, label, program, text)
import Browser
import Html exposing (button, label, text)
import Http
import I18Next
exposing
Expand All @@ -16,14 +17,14 @@ import I18Next
{-| For this example assume a remote translations file with this structure:
"""
{
"labels": {
"click-me": "Click Me"
},
"greetings": {
"hello": "Hello {{name}}"
}
}
{
"labels": {
"click-me": "Click Me"
},
"greetings": {
"hello": "Hello {{name}}"
}
}
"""
-}
Expand All @@ -38,7 +39,7 @@ type Msg


main =
program
Browser.document
{ init = init
, update = update
, view = view
Expand All @@ -48,11 +49,11 @@ main =

{-| Fetch the translations from some endpoint
-}
init =
init _ =
( Model initialTranslations Nothing
, fetchTranslations
TranslationsLoaded
"http://assets.someI18n/locale/translations.en.json"
"https://assets.someI18n/locale/translations.en.json"
)


Expand All @@ -70,10 +71,12 @@ update msg model =
{-| Use the translations in your view with or without placeholders
-}
view model =
label []
-- Use regular translations
[ text (t model.translations "labels.click-me")

-- Use translations with placeholders
, button [] [ text (tr model.translations Curly "greetings.hello" [ ( "name", "Peter" ) ]) ]
Browser.Document "I18Next example"
[ label []
-- Use regular translations
[ text (t model.translations "labels.click-me")

-- Use translations with placeholders
, button [] [ text (tr model.translations Curly "greetings.hello" [ ( "name", "Peter" ) ]) ]
]
]
Loading

0 comments on commit 30491e0

Please sign in to comment.