# Globalizing Typo 4.0.0 - S.O.S. Help needed!

**URL:** <https://www.ruby-forum.com/t/globalizing-typo-4-0-0-s-o-s-help-needed/101506>\
**Category:** Rails I18n\
**Created:** [August 5, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/globalizing-typo-4-0-0-s-o-s-help-needed/101506 "2006-08-05T13:47:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zarni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e68b1a/32.png) [@zarni](https://www.ruby-forum.com/u/zarni)\
**Post date:** [August 5, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/globalizing-typo-4-0-0-s-o-s-help-needed/101506/1 "2006-08-05T13:47:22Z")

</div>

Hello friendly rubyists! This is my first post, so bare with me 🙂

I managed to globalize Typo 4.0.0 - the static content. I made a  
Translations editor menu in the admin, and it works fine for all static  
content.

Now I am trying to globalize Article/Content.

I have done this:

class Article \< Content  
include TypoGuid

content\_fields :body, :extended

translates :body, :extended

…

Now I get this error:

=\> Booting WEBrick…  
./script/…/config/…/vendor/rails/activerecord/lib/active\_record/base.rb:1129:in  
`method_missing': undefined method`translates’ for Article:Class  
(NoMethodError)  
from script/…/config/…/app/models/article.rb:8  
from  
./script/…/config/…/vendor/rails/activesupport/lib/active\_support/dependencies.rb:140:in  
`load' from ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:56:in`require\_or\_load’  
from  
./script/…/config/…/vendor/rails/activesupport/lib/active\_support/dependencies.rb:30:in  
`depend_on' from ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:85:in`require\_dependency’  
from  
./script/…/config/…/vendor/rails/activesupport/lib/active\_support/dependencies.rb:98:in  
`const_missing' from ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:131:in`const\_missing’  
from  
./script/…/config/…/vendor/rails/activesupport/lib/active\_support/dependencies.rb:133:in  
`const_missing' ... 20 levels... from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in`require’  
from  
./script/…/config/…/vendor/rails/activesupport/lib/active\_support/dependencies.rb:147:in  
`require’  
from  
./script/…/config/…/vendor/rails/railties/lib/commands/server.rb:30  
from script/server:3

I have very little knowledge about meta programming in ruby, but I think  
it has got something to do with the way the Article ActiveRecord object  
is extending the base Content class.

I tried putting the translates method in the Categories class which does  
not extend the Content class and it works fine!

Can anyone help me solve this issue, it is very important!? Please help  
me, I am almost cluless about this problem.

Regards,  
Zarni

---

<div class="post-metadata">

**Author:** ![zarni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e68b1a/32.png) [@zarni](https://www.ruby-forum.com/u/zarni)\
**Post date:** [August 7, 2006, 10:12am UTC](https://www.ruby-forum.com/t/globalizing-typo-4-0-0-s-o-s-help-needed/101506/2 "2006-08-07T10:12:07Z")

</div>

Hi Zarni,

I’m not sure, but is Content a model based on ActiveRecord::Base?  
If not, than Article is not a model (any more) and does not define  
translates.

The content\_fields seems to a method from TypoGuid. You include the  
module  
an therefore this method exists.

Am 05.08.2006 um 13:47 schrieb Zarni Worgl:

> `load’  
> dependencies.rb:85:in  
> ./script/…/config/…/vendor/rails/activesupport/lib/active\_support/  
> from
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Railsi18n-discussion mailing list  
> removed\_email\_address@domain.invalid  
> [http://rubyforge.org/mailman/listinfo/railsi18n-discussion](http://rubyforge.org/mailman/listinfo/railsi18n-discussion)

* * *

Thomas B. - Freiberuflicher Softwarecoach  
fon: +49(40)411 622 35 mobil: +49(173)23 911 43  
fax: +49(40)411 622 36  
thomas.baustert(at)[b-simple.de](http://b-simple.de)

---

<div class="post-metadata">

**Author:** ![zarni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e68b1a/32.png) [@zarni](https://www.ruby-forum.com/u/zarni)\
**Post date:** [August 8, 2006, 2:23am UTC](https://www.ruby-forum.com/t/globalizing-typo-4-0-0-s-o-s-help-needed/101506/3 "2006-08-08T02:23:16Z")

</div>

Hey Thomas!

Content is based on ActiveRecord:Base… bellow is the head of the  
Content class and the content\_fields method is defined in it. TypoGuid  
is just a library mixin, generates unique ids. So There must be  
something clashing the Globalize mixin, which i put/included in  
environment.rb. The translates method is defined in  
Globalize::DbTranslate. I can not see why the translates method is not  
being mixed into the Content class, couse it works fine for other  
classes, that don’t have the content\_fields method.

🙂 Thanks for help

require ‘observer’  
require ‘set’

class Content \< ActiveRecord::Base  
include Observable

@@content\_fields = Hash.new  
@@html\_map = Hash.new

def initialize(\*args)  
super(\*args)  
set\_default\_blog  
end

def set\_default\_blog  
if self.blog\_id == nil or self.blog\_id == 0  
self.blog = Blog.default  
end  
end

class \<\< self  
def content\_fields(\*attribs)  
@@content\_fields[self] = ((@@content\_fields[self]||[]) +  
attribs).uniq  
@@html\_map[self] = nil  
attribs.each do | field |  
define\_method(“#{field}=”) do | newval |  
if self[field] != newval  
changed  
self[field] = newval  
if html\_map(field)  
self[html\_map(field)] = nil  
end  
notify\_observers(self, field.to\_sym)  
end  
self[field]  
end  
unless self.method\_defined?(“#{field}\_html”)  
define\_method(“#{field}\_html”) do  
if blog.controller  
html(blog.controller, field.to\_sym)  
else  
self[“#{field}\_html”]  
end  
end  
end  
end  
end

…

end

Thomas B. wrote:

> Hi Zarni,
> 
> I’m not sure, but is Content a model based on ActiveRecord::Base?  
> If not, than Article is not a model (any more) and does not define  
> translates.
> 
> The content\_fields seems to a method from TypoGuid. You include the  
> module  
> an therefore this method exists.
> 
> Am 05.08.2006 um 13:47 schrieb Zarni Worgl:
> 
> > `load’  
> > dependencies.rb:85:in  
> > ./script/…/config/…/vendor/rails/activesupport/lib/active\_support/  
> > from
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > * * *
> > 
> > Railsi18n-discussion mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://rubyforge.org/mailman/listinfo/railsi18n-discussion](http://rubyforge.org/mailman/listinfo/railsi18n-discussion)
> 
> * * *
> 
> Thomas B. - Freiberuflicher Softwarecoach  
> fon: +49(40)411 622 35 mobil: +49(173)23 911 43  
> fax: +49(40)411 622 36  
> thomas.baustert(at)[b-simple.de](http://b-simple.de)

---

<div class="post-metadata">

**Author:** ![zarni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e68b1a/32.png) [@zarni](https://www.ruby-forum.com/u/zarni)\
**Post date:** [August 8, 2006, 10:20am UTC](https://www.ruby-forum.com/t/globalizing-typo-4-0-0-s-o-s-help-needed/101506/4 "2006-08-08T10:20:07Z")

</div>

Hi Zarni,

sorry, but then I have no idea.

If you are sure it is a problem with classes that include TypoGuid  
you may uncomment all methods of TypoGuid an activate parts of the code  
one by one (maybe with some pseudo code) until you get the exception.  
Some work, but you know where the problem is.

You may switch the statements

class Article \< Content  
translates :body, :extended

include TypoGuid  
content\_fields :body, :extended

and see what happend.

You can further print out all included methods using included\_modules()  
or public\_class\_methods() für class method to see what in your class.

May that helps 🙂

Am 08.08.2006 um 02:23 schrieb Zarni Worgl:

> @@html\_map = Hash.new  
> end  
> self[field] = newval  
> html(blog.controller, field.to\_sym)  
> end
> 
> > The content\_fields seems to a method from TypoGuid. You include the
> > 
> > > `load’  
> > > removed\_email\_address@domain.invalid  
> > > –  
> > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Railsi18n-discussion mailing list  
> removed\_email\_address@domain.invalid  
> [http://rubyforge.org/mailman/listinfo/railsi18n-discussion](http://rubyforge.org/mailman/listinfo/railsi18n-discussion)

* * *

Thomas B. - Freiberuflicher Softwarecoach  
fon: +49(40)411 622 35 mobil: +49(173)23 911 43  
fax: +49(40)411 622 36  
thomas.baustert(at)[b-simple.de](http://b-simple.de)
