views:

22

answers:

1

I'm involved in preparing a pre-existing rails application for translation - going through the files under app/views/, finding the text, making a key in config/locales/de.yml (in this case), copying the text into de.yml, and putting t("key") in the view file. Repeat hundreds, maybe thousands of times. This is very tedious.

I don't think it can be fully automated, but the key things I need to do are select the text and give it a key.

So does anyone know of a tool that will automate the rest of the steps? I want to select the text, hit a key combo, type in a key, and the tool will put a key in the de.yml file, append the text, and put t("key") in place of the text that was selected.

My only key requirement is that it should run on Linux. I'm a vim user, but I'll learn Emacs if that is the best way to do it. I'll even install Eclipse if that is the best way ... I imagine that vim or emacs macros should easily be able to do the amount of work I'm asking for.

Anyone? Please?

With a bit of googling, I've managed to find a textmate plugin which would be near perfect if I had a Mac and Textmate. Something similar would be great.

+1  A: 

Normally for those cases I use, I18n::Backend::Database (ActiveRecord Adapter for storing translations in the database). This has one major advantage that might also be helpful for your case, I can store translations without the key syntax.

Suppose you have this text <%= link_to 'Das ist ein Link Text', root_url %> You could transform it to this with I18n::Backend::Database <%= link_to t('Das ist ein Link Text'), root_url %>.

Using this you could create a quick Textmate/Emacs/Vim shortcut to just basiclly wrap the t() around a string.

Does that solve your problem?

Max Schulze