# Script to extract text from application

**URL:** <https://www.ruby-forum.com/t/script-to-extract-text-from-application/156827>\
**Category:** Rails I18n\
**Created:** [January 3, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/script-to-extract-text-from-application/156827 "2009-01-03T18:25:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuktuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tuktuk](https://www.ruby-forum.com/u/tuktuk)\
**Post date:** [January 3, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/script-to-extract-text-from-application/156827/1 "2009-01-03T18:25:02Z")

</div>

I accidentally posted this question in the Rails forum, but it might fit  
better here…

I have a Rails application, that has grown quite large. At the moment  
all texts are placed inside the template files like this:

### This is a header

And inside the ruby code (like flash messages, model error messages,  
etc.)

I now have the situation, that I want to place all text in an external  
textfile in order to be able to e.g. translate the entire site.

Is there an easy way to extract all these texts and replace them with  
e.g.

l(:some\_text\_key) in the ruby code and

\<%=l(:some\_text\_key) in the templates?

or do I have to go through all files manually? (yikes)

BTW: I will happily move to Rails 2.2 if that is any help.

- Carsten

---

<div class="post-metadata">

**Author:** ![tuktuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tuktuk](https://www.ruby-forum.com/u/tuktuk)\
**Post date:** [January 2, 2010, 4:38pm UTC](https://www.ruby-forum.com/t/script-to-extract-text-from-application/156827/2 "2010-01-02T16:38:03Z")

</div>

Check out the ready\_for\_i18n tool at

> **[GitHub - zigzag/ready\_for\_i18n: A handy tool helping transfer your local...](https://github.com/zigzag/ready_for_i18n)**
>
> A handy tool helping transfer your local Rails project to an i18n one by extracting text from HTML and helper methods. - GitHub - zigzag/ready\_for\_i18n: A handy tool helping transfer your local Rai...

An introduction blog at:  
[http://zigzag.github.com/2009/12/17/get-your-local-rails-application-ready-for-i18n.html](http://zigzag.github.com/2009/12/17/get-your-local-rails-application-ready-for-i18n.html)

Carsten G. wrote:

> I accidentally posted this question in the Rails forum, but it might fit  
> better here…
> 
> I have a Rails application, that has grown quite large. At the moment  
> all texts are placed inside the template files like this:
> 
> ### This is a header
> 
> And inside the ruby code (like flash messages, model error messages,  
> etc.)
> 
> I now have the situation, that I want to place all text in an external  
> textfile in order to be able to e.g. translate the entire site.
> 
> Is there an easy way to extract all these texts and replace them with  
> e.g.
> 
> l(:some\_text\_key) in the ruby code and
> 
> \<%=l(:some\_text\_key) in the templates?
> 
> or do I have to go through all files manually? (yikes)
> 
> BTW: I will happily move to Rails 2.2 if that is any help.
> 
> - Carsten

---

<div class="post-metadata">

**Author:** ![tuktuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tuktuk](https://www.ruby-forum.com/u/tuktuk)\
**Post date:** [January 2, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/script-to-extract-text-from-application/156827/3 "2010-01-02T18:22:36Z")

</div>

Zigzag Chen wrote:

> Check out the ready\_for\_i18n tool at  
> [GitHub - zigzag/ready\_for\_i18n: A handy tool helping transfer your local Rails project to an i18n one by extracting text from HTML and helper methods.](http://github.com/zigzag/ready_for_i18n)
> 
> An introduction blog at:  
> [http://zigzag.github.com/2009/12/17/get-your-local-rails-application-ready-for-i18n.html](http://zigzag.github.com/2009/12/17/get-your-local-rails-application-ready-for-i18n.html)

Very neat 🙂

I’ve been experimenting with that myself as well. But it only gets me  
half the way, since controller code contains texts as well.

Anyway this is an old question and since then I’ve extracted all texts  
by hand. But thanks anyway. 🙂

- Carsten
