Forum: Ruby on Rails Globalize : how to detect if a translated text is available

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Gerard de Brieder (Guest)
on 2006-04-20 12:42
(Received via mailing list)
Hi all,

I was wondering how one can detect if a translated text is available
when using the globalize plugin.
If this is possible , then I would like to make the following :

For example, in your view you have :
<removed_email_address@domain.invalid { | item | %>

Now what I would like to happen is , when the menu item has no
translation available , and when a admin is logged in (by checking
the session vars) it shows a little icon which will be clickable to
insert the translation of that item.

Please share your thoughts on this,

Gerard de Brieder.

tel : +31624739047
Gerard de Brieder (Guest)
on 2006-04-20 13:31
(Received via mailing list)
Hi all,

Just sharing my findings in the mean while...

I did find out that the object will have an attributed called
<field_name>_not_base so you could make a condition like :
<%="(Translated)" if @text.body_not_base  rescue "(Translation not
Gerard de Brieder (Guest)
on 2006-04-20 14:05
(Received via mailing list)
Current progress :
I made an helper like this :

def translate(object,attribute)
     unless object.nil?
       unless Locale.base?
         if object.send("#{attribute}_not_base")
           ret+="(No translation available)<br>".t
        ret="Text not available".t
      return ret

Which works quite well, ofcourse i can no extent it when the
translation is not avaiable to make the controls to change it....
I would appreciate it if someone could show me how to beautify the
piece of code above...
This topic is locked and can not be replied to.