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

textfinder/textreplacer #17

Open
shaiguitar opened this issue May 16, 2013 · 2 comments
Open

textfinder/textreplacer #17

shaiguitar opened this issue May 16, 2013 · 2 comments

Comments

@shaiguitar
Copy link

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!

@douglasjsellers
Copy link
Owner

Hi!

Nice job with haml-i18n-extractor! Looks like you are off to a good start.

HerbGobble does do things similar to what you are showing but uses TreeTop grammers (https://github.com/douglasjsellers/herbgobbler/blob/master/grammer/erb_grammer.treetop) to do it, since at least with erb the problem becomes insoluble when using reg-exs. This is actually the third version of this tool that I built to attack this problem. The first one attempted to use reg-exs before it became to complex.

The fundamental problem ends up being that when you have html like this (in whatever markup you like)

I love text that I am making different colors.. It makes me very happy.

Translators want that all to extract as one key. To do that you have to coherce your input into an AST in some way so that you can apply a transformation on that AST to output different markup as well as into your translation store of choice.

Blah blah blah blah.

Anyway, if you are interested into making it work for HAML I would love to help out. Let me know!

@shaiguitar
Copy link
Author

I think I had the relative easy route compared to ERB, because I can just use the HAML code to check what node type it is. eg simple text/element/eval-code nodes etc. So at this point I don't think I need to convert it to treetop, it seems to be doing it's job quite well, all in all.

If you do, or know anyone who uses HAML and needs to I18n, please let them know about it! That way I can gather more feedback and make it better if need be.

For reference, a quick demo usage of the tool (it's in the repo as well, linked from README): http://shairosenfeld.com/haml-i18n-extractor-demo.swf

Also if you have any ideas how we can incorporate these two tools together to create a comprehensive one, I think it could benefit the community immensely.

If you think about it I would say the vast majority of view templates laying around in the rails world split between HAML and ERB, and having some generic tool to do this would be ... hmm: awesome. To say the least ;) .

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

2 participants