-
Notifications
You must be signed in to change notification settings - Fork 276
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
Add support for meta tags in locales #84
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ module ControllerHelper | |
|
||
included do | ||
alias_method_chain :render, :meta_tags | ||
before_filter :meta_tags_from_locales | ||
end | ||
|
||
# Processes the <tt>@page_title</tt>, <tt>@page_keywords</tt>, and | ||
|
@@ -27,6 +28,19 @@ def render_with_meta_tags(*args, &block) | |
end | ||
protected :render_with_meta_tags | ||
|
||
# Processes meta tags from locales file in the name space | ||
# [locale].meta_tags.[controller_name].[action].[title|description|keywords] | ||
# So en.meta_tags.visitors.index.title would be loaded as title for default | ||
# welcome page in the visitors controller in english. | ||
def meta_tags_from_locales | ||
name_space = "meta_tags.#{controller_name}.#{action_name}" | ||
|
||
self.meta_tags[:title] = I18n.t("#{name_space}.title") unless I18n.t("#{name_space}.title", default: '').blank? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [123/80] |
||
self.meta_tags[:keywords] = I18n.t("#{name_space}.keywords") unless I18n.t("#{name_space}.keywords", default: '').blank? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [129/80] |
||
self.meta_tags[:description] = I18n.t("#{name_space}.description") unless I18n.t("#{name_space}.description", default: '').blank? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [135/80] |
||
end | ||
protected :meta_tags_from_locales | ||
|
||
# Set meta tags for the page. | ||
# | ||
# See <tt>MetaTags::ViewHelper#set_meta_tags</tt> for details. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment Branch Condition size for meta_tags_from_locales is too high. [17.29/15]