-
Notifications
You must be signed in to change notification settings - Fork 264
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
I want i18n-tasks to ensure a '.title' whenever I use a headline_with_flash
in a view
#138
Comments
You can extend the scanner, or work around with a magic comment: / i18n-tasks-use t('.title')
= headline_with_flash |
Extending the scanner sounds promising, but it looks very complicated. Could you point me into the right direction, please? |
You could try something like below (untested code): In class MyI18nScanner < I18n::Tasks::PatternScanner
def scan_file(path, opts = {})
keys = super
if path =~ /\.(slim|haml)$/
text = opts[:text] || read_file(path)
text.scan(/^\s*=\s*headline_with_flash\b/) do |pattern|
location = src_location(path, text, Regexp.last_match.offset(0).first)
keys << [absolute_key('.title', path, location), data: location]
end
end
keys
end
end In
It would be great if i18n-tasks supported multiple scanners (#81). |
If this works out for you, please add a wiki article 👍 |
I didn't have the time to really check it out. It's on my TODO list though. Thanks! |
This is now very easy with the |
I'm using a method called
headline_with_flash
in most of my views:The method looks like this:
The method lives in
page_title_and_headline_helper.rb
and I had to exclude this file usingOtherwise, i18n-tasks would fail:
So now I'd like i18n-tasks to make sure that whenever it meets a call to
headline_with_flash
in a view, it checks whether a corresponding.title
key exists in the translations.Is this possible?
The text was updated successfully, but these errors were encountered: