Add function generation
Description
This MR introduces breaking changes to the I18n workflow.
CLI arguments
You need to define a language as argument to the elm-i18n cli:
elm-i18n generate en_us
elm-i18n watch en_us
Named Holes
{
"Hello": "Hello {user}!"
}
Function generation
Now there the translations are not longer custom type variants, instead functions with records are arguments are generated. Lets take a look a an exmaple:
Assume this json:
{
"Hello": "Hello {user}!"
}
will generate:
hello : { user : String } -> String
hello argument =
"Hello " ++ argument.user ++ "!"
Now the useage of the I18n
module needs to be updated:
-- from this
I18n.t (TidHello "Peter")
-- into this
I18n.hello { user = "Peter" }
Due the dead-code-elimination of the elm compiler, all functions which are not used are removed. This will reduce the bundle a bit.
CI/CD
We will run the test for the generation and a test for the examples in a ci pipeline.
Edited by Hauke Ingwersen