# GetText and rjs templates?

**URL:** <https://www.ruby-forum.com/t/gettext-and-rjs-templates/53209>\
**Category:** Rails\
**Created:** [January 29, 2006, 3:39am UTC](https://www.ruby-forum.com/t/gettext-and-rjs-templates/53209 "2006-01-29T03:39:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trung](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/4bbf92/32.png) [@trung](https://www.ruby-forum.com/u/trung)\
**Post date:** [January 29, 2006, 3:39am UTC](https://www.ruby-forum.com/t/gettext-and-rjs-templates/53209/1 "2006-01-29T03:39:16Z")

</div>

hi,

is it possible that gettext don’t work with rjs templates?

i’ve just tried this simple example

blog\_controller.rb :

class BlogController \< ApplicationController  
def index

```
end
def dosomething

end

```

end

index.rhtml :

\<%= javascript\_include\_tag :defaults %\>
Some text to change 
\<%= link\_to\_remote 'click', :url =\> {:action =\> 'dosomething'} %\>

and the rjs template  
dosomething.rjs :  
page.replace\_html ‘test’, ‘ruby on rails’

this works fine until i add

init\_gettext “blog”

to my application.rb  
no errors from the server, the div just don’t update its contents  
anymore.

what’s wrong??

---

<div class="post-metadata">

**Author:** ![trung](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/4bbf92/32.png) [@trung](https://www.ruby-forum.com/u/trung)\
**Post date:** [January 29, 2006, 4:20am UTC](https://www.ruby-forum.com/t/gettext-and-rjs-templates/53209/2 "2006-01-29T04:20:11Z")

</div>

On 1/28/06, Trung T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= javascript\_include\_tag :defaults %\>
> 
> this works fine until i add
> 
> init\_gettext “blog”
> 
> to my application.rb  
> no errors from the server, the div just don’t update its contents  
> anymore.
> 
> what’s wrong??

We saw something similar at work but haven’t gotten to the bottom of  
it yet. It _looks_ like there is a problem with the to\_json code, but  
I can’t say for sure.

–  
Chad F.  
[http://chadfowler.com](http://chadfowler.com)  
[http://www.pragmaticprogrammer.com/titles/fr\_rr/](http://www.pragmaticprogrammer.com/titles/fr_rr/) (Rails Recipes coming  
SOON)  
[http://pragmaticprogrammer.com/titles/mjwti/](http://pragmaticprogrammer.com/titles/mjwti/) (My Job Went to India,  
and All I Got Was This Lousy Book)  
[http://rubycentral.org](http://rubycentral.org)  
[http://rubygarden.org](http://rubygarden.org)  
[http://rubygems.rubyforge.org](http://rubygems.rubyforge.org) (over one million gems served!)

---

<div class="post-metadata">

**Author:** ![trung](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/4bbf92/32.png) [@trung](https://www.ruby-forum.com/u/trung)\
**Post date:** [January 30, 2006, 5:43pm UTC](https://www.ruby-forum.com/t/gettext-and-rjs-templates/53209/3 "2006-01-30T17:43:17Z")

</div>

Hi,

On Sun, 29 Jan 2006 03:39:16 +0100  
Trung T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= javascript\_include\_tag :defaults %\>
> 
> this works fine until i add
> 
> init\_gettext “blog”
> 
> to my application.rb  
> no errors from the server, the div just don’t update its contents  
> anymore.
> 
> what’s wrong??

Oops, it’s a bug(?) of Ruby-GetText.

Remove the line 68 of gettext/rails.rb, please.  
#(e.g.) /usr/lib/ruby/gems/1.8/gems/gettext-1.1.1/lib/gettext/rails.rb

```
:
:
def init_gettext_main
  bindtextdomain(@@gettext_domainname, request.cgi) #You need to 

```

pass CGI object first.

# Remove a line below

# @headers[“Content-Type”] = "#{@@gettext\_content\_type};

charset=#{GetText.output\_charset}"  
end  
:  
:
