Skip to content
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

Parsing .coffee files in views as erb #158

Closed
coffeebite opened this issue Jun 13, 2016 · 6 comments
Closed

Parsing .coffee files in views as erb #158

coffeebite opened this issue Jun 13, 2016 · 6 comments

Comments

@coffeebite
Copy link

I have files with .js.coffee extension in my rails views. Rails automatically parses .coffee files in views as ERBs without requiring the .erb extension. I'd like the gettext:find task to parse my .coffee files in views folders like ERB files and extract translations from them. How do I do that? I have changed the files_to_translate method by adding this to lib/tasks/gettext.rake:

namespace :gettext do
  def files_to_translate
    Dir.glob("{app,lib,config,locale}/**/*.{rb,erb}") + Dir.glob("app/views/**/*.coffee")
  end
end

I also added this line in gettext.rake

GetText::ErbParser.init(extnames: ['.erb', '.coffee'])

But it doesn't work.

@grosser
Copy link
Owner

grosser commented Jun 13, 2016

not sure even js is supported ... maybe find that first ... alternatively
write some custom script that extracts the i18n calls and dumps them into a
addional.rb file that gettext will that understand/parse

On Sun, Jun 12, 2016 at 10:29 PM, coffeebite notifications@github.com
wrote:

I have files with .js.coffee extension in my rails views. Rails
automatically parses .coffee files in views as ERBs without requiring the
.erb extension. I'd like the gettext:find task to parse my .coffee files
in views folders like ERB files and extract translations from them. How do
I do that? I have changed the files_to_translate method by adding this to
lib/tasks/gettext.rake:

namespace :gettext do
def files_to_translate
Dir.glob("{app,lib,config,locale}//*.{rb,erb}") + Dir.glob("app/views//*.coffee")
endend

I also added this line in gettext.rake

GetText::ErbParser.init(extnames: ['.erb', '.coffee'])

But it doesn't work.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#158, or mute the
thread
https://github.com/notifications/unsubscribe/AAAsZw-vHOOgZHga10RhY5xKFf_JsGEbks5qLOrUgaJpZM4I0AaE
.

@coffeebite
Copy link
Author

Thanks for the response, Mike. I can try that. Though, is there a simple way for me to specify that, on top of .erb and .rhtml, .coffee files should also be processed by the Erb parser?

@grosser
Copy link
Owner

grosser commented Jun 13, 2016

Don't know how that would be done, but should be possible if you find
whatever does the erb parsing ..

On Mon, Jun 13, 2016 at 8:42 AM, coffeebite notifications@github.com
wrote:

Thanks for the response, Mike. I can try that. Though, is there a simple
way for me to specify that, on top of .erb and .rhtml, .coffee files should
also be processed by the Erb parser?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#158 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAsZ10xXFfizkMHmm-AeIujOloHwYvDks5qLXpLgaJpZM4I0AaE
.

@coffeebite
Copy link
Author

Thanks, Mike. I'll dig around.

@artemv
Copy link

artemv commented Oct 12, 2016

@coffeebite, parsing of both JS and Coffee (and some other blends of JS including JSX now) are supported if you add https://github.com/webhippie/gettext_i18n_rails_js gem.

@grosser
Copy link
Owner

grosser commented Oct 12, 2016

might want to link that in the readme ... closing for now ...

@grosser grosser closed this as completed Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants