Releases: ChristophP/elm-i18next
Adding `customTr` and `customTrf`
Now it's possible to have placeholders and replace them with things other than string such as Html
. This feature helps so that translators don't have to break up their text into little pieces when the text contains markup such as a link for example.
Thanks @csicar for suggesting the feature and providing much of the implementation.
Adding custom translation constructors
This release adds the possibility for users to build their own translations without decoding JSON.
- exposes functions to construct a
Translations
type - do some internal refactoring
- make decoder fail if it is passed a string instead of an object
No more http dependency, some meta functions
- Removes
fetchTranslations
and the dependency onelm/http
. Since the elm compiler does not support having multiple version of the same library it is better not to depend onelm/http
so that users can choose more freely whether to useelm/http
version 1 or 2. Also, I assume thatfetchTranslations
was not highly used and can easily be built by users. - Add
keys
andhasKey
function. This should not be needed for regular applications but exposing them allows makers of translation editors to query for missing keys or check if keys exists. - Add a proper example, in which the default case is passing the translations via flags. The case where Elm makes an Http request for the translations file should be added soon.
Update tests and examples for 0.19
Merge pull request #10 from ChristophP/adjust-tests-and-docs-for-19 Adjust tests and docs for 19
2.0.0
- Fix another bug in the decoder that was producing wring keys in the decoded translations.
- Make the
Translations
type opaque - Add
tr
function for translating with replacements(placeholders). - Add
tf
function for translating while uses fallback languages. - Add
trf
function for using replacements(placeholders) and fallback languages at the same time. - change API to "translations first" for easier use with pipelines.
- improve docs and readme.
Fix another decoder bug
This patch fixes antother bug in the decoder that messed up nested translations.
Fix decoder bug
This patch fixes a bug that existed in the decoder for the translation files. The namespace was cleared for all nested keys expect the first one.
With the bug a JSON file like this :
{
"a": {
"b": "hello",
"c": "bye"
}
}
was decoded into Dict.fromList [("a.b","Hello"),("c","bye")]
instead of Dict.fromList [("a.b","Hello"),("b.c","bye")]
.
Decoding now works properly for all nested keys.