I’m using Rails built in I18n (Simple backend). I’ve set the default locale to :en and enabled fallbacks. Let’s say I have translations for a specific item in English and Spanish. Now a German visitor comes to my site and it falls back to English. How would I go about detecting that fallback and wrapping it in a span?
<span class="fallback">Hello</span> instead of just Hello
This way I could then use client side machine translations.
I’m hoping to avoid writing my own backend to replace “Simple”.
Had to resort to over-riding the translate function in I18n::Backend::FallBacks
https://github.com/svenfuchs/i18n/blob/master/lib/i18n/backend/fallbacks.rb
I just put this code in an initializer.
It feels very messy to me… I would still love to mark someone else’s better answer as correct.