crbelaus / trans

Embedded translations for Ecto
https://hex.pm/packages/trans
Apache License 2.0
231 stars 18 forks source link

Translator.translate/2 should fall back to default locale when translation is missing #84

Closed krns closed 4 months ago

krns commented 6 months ago

The added test currently fails, but should work IMO. When the desired translation is missing the translatable field is nil:

  1) test &Trans.Translator.translate/2 falls back to the default locale if translation does not exist (Trans.TranslatorTest)
     test/trans/translator_test.exs:48
     Assertion with == failed
     code:  assert translated.content == struct.content
     left:  nil
     right: "Content EN"
     stacktrace:
       test/trans/translator_test.exs:51: (test)
krns commented 5 months ago

@crbelaus, in case you missed it. At first I had only added a test, but I have since added the fix as well. If any adjustments are still necessary, I will be happy to address them.

crbelaus commented 5 months ago

Hey @krns! Thanks for the heads up, I had completely forgot about this.

I will take a look at it this weekend!

crbelaus commented 4 months ago

This is great, and the test works perfectly for me.

Thanks a lot @krns!

crbelaus commented 4 months ago

I've just published Trans 3.0.1 with this fix!