Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

krns
Copy link
Contributor

@krns krns commented May 29, 2024

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 krns changed the title Translator.translate/2 should fall back to default locale when local is missing Translator.translate/2 should fall back to default locale when translation is missing May 29, 2024
@krns
Copy link
Contributor Author

krns commented Jun 27, 2024

@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
Copy link
Owner

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

I will take a look at it this weekend!

@crbelaus crbelaus merged commit 22a54ad into crbelaus:main Jul 7, 2024
@crbelaus
Copy link
Owner

crbelaus commented Jul 7, 2024

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

Thanks a lot @krns!

@crbelaus
Copy link
Owner

crbelaus commented Jul 7, 2024

I've just published Trans 3.0.1 with this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants