How do I limit the result set of a query to records that have a translation for the current locale (or fallback) while leaving out any records that don't?
For example, given a locale of :fr
, I only want Article.all
to return only articles that have a French translation. Same with :'fr-FR'
—I want to return any record that has a translation locale of :'fr-FR'
or :fr
, but nothing else.
Article.joins(:translations).where(article_translations: { locale: [I81n.locale] })
works for a single location, but what about fallbacks?