Open tozz opened 3 months ago
@tozz, thanks for the very complete report, greatly appreciated.
You are seeing the behaviour as implemented. But I'm not sure either if it's the right behaviour. Fair to say the user population of this lib isn't high so it's hard to get a feeling for expectations. At minimum the documentation clearly needs improvement.
Part of the challenge is that sometimes the translation is resolved in a database query and sometimes in Elixir - no matter what the two need to agree on the fallback strategy. Today, the database query expects a translation to be available.
The primary question then is: should the default be returned when a locale is configured but a translation is not available.
What makes the most sense to you?
Regarding the user population I think it's a missed opportunity for them, I love the lib and the Elixir CLDR ecosystem as a whole, makes life a lot easier, so thank you for all the effort :)
I feel like the consistent way would be preferred, so a change from today so that the default is returned when a locale is configured but a translation is not available. That would align it with how the fallback chain and "get by field" works.
Makes sense to me, and thank you for the kind words. I'll tackle this ASAP but since I'm on the road it might take a few days.
I've push a commit that fixes this issue I believe, would you consider giving this a spin using the main
branch? If you're ok, I'll add some additional tests and publish an update.
Thanks for the quick turn around, I actually don't see any difference with running this from main, I made sure to wipe deps
and _build
too, but behavior is the same.
@tozz, sorry for wasting your time. I'm a bit perplexed because my testing seems to show the correct results for your example. I'll go back and test more closely to your examples.
I have a very basic setup (anonymized a bit)
I then want to translate a struct but it fails if the locale has been configured but the translation is missing.
If I use a locale that is not configured the fallback works as expected.
And finally, when using a fallback chain it also works as expected.
Giving the field also works as expected.
So there's clearly some kind of mismatch here, or I am not reading the docs correctly. I'm fine with the behavior now that I understand why it happens, but it took a while, is it a bug or expected behaviour?