Skip to content

Instantly share code, notes, and snippets.

@mrakowski0
Last active December 18, 2015 07:38
Show Gist options
  • Select an option

  • Save mrakowski0/5747691 to your computer and use it in GitHub Desktop.

Select an option

Save mrakowski0/5747691 to your computer and use it in GitHub Desktop.
Ruby helper for I18n meta tags support.
def t_meta(meta)
path = request.path_info.gsub(/^(.*)\//, "")
translation_path = "t.head.#{meta}.#{path} | t.head.#{meta}.#{params[:locale]}"
eval translation_path
end
head:
description:
home: Your index description
offer: Our offer is just great
contact: Contact us immediately
title:
home: Best website in the world!
offer: Our offer is through the roof
contact: Sky's the limit
%head
...
%meta{:description => "#{t_meta(:description)}"}
...
%title= t_meta(:title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment