douglasjsellers / herbgobbler Goto Github PK
View Code? Open in Web Editor NEWTool for Text Extraction from erb/rhtml files for internationalization (i18n) purposes
Home Page: http://herbgobbler.com
Tool for Text Extraction from erb/rhtml files for internationalization (i18n) purposes
Home Page: http://herbgobbler.com
When the tool extracts translations it puts them in keys like this
devise:
confirmations:
newhtmlerb:
Rails can't find them. If I remove the htmlerb part it's fine.
Repro.
run herbgobbler once.
run it again
/usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/rails_translation_store.rb:91:in escape': undefined method
gsub' for nil:NilClass (NoMethodError)
from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/rails_translation_store.rb:74:in block in serialize' from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/base_translation_store.rb:14:in
block (2 levels) in each'
from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/base_translation_store.rb:12:in each' from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/base_translation_store.rb:12:in
block in each'
from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/base_translation_store.rb:11:in each' from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/base_translation_store.rb:11:in
each'
from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/core/rails_translation_store.rb:55:in serialize' from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/commandline/gobble_all.rb:64:in
block in execute_i18n'
from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/commandline/gobble_all.rb:64:in open' from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/commandline/gobble_all.rb:64:in
execute_i18n'
from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/lib/commandline/gobble_all.rb:17:in execute' from /usr/local/lib/ruby/gems/2.1.0/gems/herbgobbler-0.3.11/bin/gobble:32:in
<top (required)>'
from /usr/local/bin/gobble:23:in load' from /usr/local/bin/gobble:23:in
This is a diff for the respective line. For repro, install the devise gem and generate the devise views( devise/registrations/edit.html.erb)
Hey, great library! I was working on an equivalent of this for haml, as you can see here:
https://github.com/shaiguitar/haml-i18n-extractor
That lib has got an interactive executable as you can see the demo on the README file. I'm not familiar with the herbgobbler internals, so I was wondering if you have a concept similar to what is here:
https://github.com/shaiguitar/haml-i18n-extractor/blob/master/test/text_finder_test.rb
https://github.com/shaiguitar/haml-i18n-extractor/blob/master/test/text_replacer_test.rb
If you did, I was thinking I could merge those concepts into the existing tool, or create a superset tool that would encompass both libraries, and abstract the templates they are working on, and just be a template-i18n-replacing library of sorts.
Hope that makes sense.
Also, if you do use haml or know anyone who does, I would be curious to know if you have any feedback about the above tool.
Thanks!
Herbgobbler extract incorrectly the ร in ร
It transforms it into t .times.
Ps. Thanks for this. It's very cool
It would be great if one could configure how the translation is done. For example, I prefer t('.some_key') instead of the current output t '.some_key'. It would be great if I could chose that.
I have a link_to with a confirm: key added to it. Herbgobbler transfers the text of the link, but not the confirm. It would be great if it would move the confirm to the translation files, as well
Before gobble i18n -a .
-<%= link_to '| Leave course', @course_subscription, method: :delete, remote:true, confirm: "All your progress will be lost, are you sure you want to leave course?" %>
After.
+<%= link_to (t '.leave_course'), @course_subscription, method: :delete, remote:true, confirm: "All your progress will be lost, are you sure you want to leave course?" %>
It would be great if the confirm text would be added as well
Hey,
nice approach. the automatization is great. i think it would be nice to have some more user input.... if i could enter the translation key t("dashboard.recent_entries") and optional the tranlation for each string found in view files. finding already translated keys in the view would be good (for refactoring purpose).
the full automatization would only work in some cases for me, espacialy if i have to refactor a project or add translation later on.
best, Kalle
The tool doesn't consider -f flag.
gobble i18n -f app/views/home/home.html.erb
***** HerbGobbler Usage *****
Options
tr8n | i18n : Use the normal rails i18n output format or use tr8n output
-a : Process an entire Rails Code Base
-f : Process a single file
Usage: gobble tr8n -a
Herbgobbler gets confused on the following line:
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
This is what it generates
<%= t '.unhappy', :button_to => (button_to (t '.cancel_my_1'), registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete) %>
en.yml:
cancel_my_1: "Cancel my account"
unhappy: "Unhappy? %{button_to}"
In my opinion, this would be simpler like this:
t('.unhappy') <%= button_to t('.cancel_my'), registration_path(resource_name), data: { confirm: t('.are_you_sure')}, method: :delete %>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.