Created
October 9, 2011 01:15
-
-
Save stas/1273142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'gettext/tools.rb' | |
| require 'tenjin' | |
| require 'ruby_parser' | |
| require 'gettext_i18n_rails/ruby_gettext_extractor' | |
| begin | |
| require 'gettext/tools/rgettext' | |
| rescue LoadError #version prior to 2.0 | |
| require 'gettext/rgettext' | |
| end | |
| ## | |
| # Gettext parser for `fast_gettext` gem | |
| # This should fix template tags like these `#{_'String'}` in Tenjin | |
| # | |
| # Invoke with `rgettext -r ./tenjin_gettext_parser.rb view/*` | |
| module GettextI18nRails | |
| module TenjinParser | |
| module_function | |
| def target?(file) | |
| File.extname(file) == '.rbhtml' | |
| end | |
| def parse(file, msgids = []) | |
| tmpl = Tenjin::Template.new | |
| code = tmpl.convert_file(file) | |
| RubyGettextExtractor.parse_string(code, file, msgids) | |
| end | |
| end | |
| end | |
| GetText::RGetText.add_parser(GettextI18nRails::TenjinParser) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment