Thank you for this package, it looks amazing. Not sure if this is an issue, or it's me. I've tried pinging you on slack, before opening this issue. Since I'm not sure what's going on, it could be a bug or not. I believe I've done everything right, but all I get are keys rather than values. I believe that t is always returning the Maybe.withDefault key for some reason.
{
"init": {
"api": "https://random-words-api.vercel.app/word",
"message": "START TYPING TO MATCH THE WORD ABOVE"
},
"screen": {
"word": "Your word is:",
"definition": "Definition:",
"pronunciation": "Pronunciation:"
},
"command": {
"erase": "ERASE [↤]",
"reset": "RESET [5]",
"speak": "SPEAK [8]",
"spell": "SPELL [9]",
"submit": "SUBMIT [↵]",
"retry": "RETRY [6]",
"new": "NEW [0]",
"soundOn": "SOUND ON [2]",
"soundOff": "SOUND OFF [3]"
}
}
main.js:
// translations defaults to English
let translations = fetch('translations/translations.en.json')
// Start the Elm application.
const app = Elm.SpeakAndSpell.init({
node: document.querySelector('main'),
flags: translations
})
// Language select for the translation file
app.ports.language.subscribe(function (message) {
translations = fetch('translations/translations.' + message + '.json')
})
initialModel:
initialModel : Encode.Value -> ( Model, Cmd Msg )
initialModel encodedJson =
let
initLocale : Translations
initLocale =
case Decode.decodeValue translationsDecoder encodedJson of
Ok translations ->
translations
Err _ ->
initialTranslations
in
( { status = Loading
, output = Init
, sound = On
, lang = En
, translations = initLocale
, newWord =
{ word = "INIT"
, definition = ""
, pronunciation = ""
}
, guessWord = ""
, checkWord = ""
, result = ""
}
, getNewWordCmd
)
example usage (omitting lots of code, but it's clear):
import Translations.Init as TRinit
outputText : Model -> String
outputText model =
case model.output of
Init ->
TRinit.message model.translations
|> String.toUpper
Word ->
model.guessWord
Result ->
model.result
Hi @ChristophP
Thank you for this package, it looks amazing. Not sure if this is an issue, or it's me. I've tried pinging you on slack, before opening this issue. Since I'm not sure what's going on, it could be a bug or not. I believe I've done everything right, but all I get are
keys
rather thanvalues
. I believe thatt
is always returning theMaybe.withDefault key
for some reason.Here are a few details:
elm-i18next
with yonigibbs/elm-i18next-gen to generate theTranslations
files:elm-i18next-gen --source public/translations/translations.en.json --target src/elm --overwrite
Please and thank you