impress/lib/fragment_localization.rb
Matchu 99f5cd717f Move some model mixins to lib/
The models folder is a bit confusingly large, these are more mixins and
kinda clutter it. Push them off into `lib`, I think!

I think they used to be in models mainly because Rails used to handle
`lib` differently with autoloading, and it made for a worse dev
experience. Now it's all the same, though!
2023-12-05 14:55:31 -08:00

11 lines
277 B
Ruby

module FragmentLocalization
def localize_fragment_key(key, locale)
if key.is_a?(Hash)
{:locale => locale}.merge(key)
elsif key.is_a?(String)
"#{key} #{locale}"
else
raise TypeError, "unexpected fragment key type: #{key.class}"
end
end
end