I18n on column description

31 views
Skip to first unread message

G. Sobrinho

unread,
Jul 1, 2009, 6:22:39 PM7/1/09
to activescaffold
Hello,

I'm working on new project using ActiveScaffold and now I need to internationalize the column descriptions.
I think the best form is create a method named human_description (ie: Category.human_description :name) and create a method which overwrite the ActiveScaffold to show it automatically if have.


What you think?


Thanks

--
Regards,

Gabriel Sobrinho
E-mail: gabriel....@gmail.com
Phone: +55 31 8775 8378

Don't print this e-mail. The nature is thankful and your money also.

G. Sobrinho

unread,
Jul 1, 2009, 7:35:05 PM7/1/09
to ActiveScaffold : Ruby on Rails plugin
Looking on ActiveScaffold source I found this method in vendor/plugins/
active_scaffold/lib/active_scaffold/data_structures/column.rb:

def description
@description.is_a?(Symbol) ? as_(@description, {:scope =>
[:activerecord, :attributes,
active_record_class.to_s.underscore.to_sym]}) : as_(@description) if
@description
end

That works using "config.columns[:column].description
= :column_description" but this is not comfortable because I need to
write it for all column which I need a description using a name
like :name_description.

I written a small "plugin" with around 3 lines which change this
behavior.
See here: http://pastie.org/private/ptkhq6vszabqq5crfvt6a

Now it's full automatic. I write the description in the locale file
(example in pastie link) and it's shown on ActiveScaffold. I think
this works more comfortable than the actual form.

Can ActiveScaffold change this behavior if ActiveScaffold users liked
that?


Thanks

On 1 jul, 19:22, "G. Sobrinho" <gabriel.sobri...@gmail.com> wrote:
> Hello,
>
> I'm working on new project using ActiveScaffold and now I need to
> internationalize the column descriptions.
> I think the best form is create a method named human_description (ie:
> Category.human_description :name) and create a method which overwrite the
> ActiveScaffold to show it automatically if have.
>
> What you think?
>
> Thanks
>
> --
> Regards,
>
> Gabriel Sobrinho
> E-mail: gabriel.sobri...@gmail.com

Sergio Cambra .:: entreCables S.L. ::.

unread,
Jul 2, 2009, 3:55:30 AM7/2/09
to actives...@googlegroups.com
On Jueves, 2 de Julio de 2009 01:35:05 G. Sobrinho escribió:
> Looking on ActiveScaffold source I found this method in vendor/plugins/
> active_scaffold/lib/active_scaffold/data_structures/column.rb:
>
> def description
> @description.is_a?(Symbol) ? as_(@description, {:scope =>
> [:activerecord, :attributes,
> active_record_class.to_s.underscore.to_sym]}) : as_(@description) if
> @description
> end
>
> That works using "config.columns[:column].description
> = :column_description" but this is not comfortable because I need to
> write it for all column which I need a description using a name
> like :name_description.
>
> I written a small "plugin" with around 3 lines which change this
> behavior.
> See here: http://pastie.org/private/ptkhq6vszabqq5crfvt6a
>
> Now it's full automatic. I write the description in the locale file
> (example in pastie link) and it's shown on ActiveScaffold. I think
> this works more comfortable than the actual form.
>
> Can ActiveScaffold change this behavior if ActiveScaffold users liked
> that?

I have changed behavior with your suggestion, but I have kept attr_writer
:description, and when description is set, is returned without translation, so
people who don't use I18n can set description.

Thanks

>
>
> Thanks
>
> On 1 jul, 19:22, "G. Sobrinho" <gabriel.sobri...@gmail.com> wrote:
> > Hello,
> >
> > I'm working on new project using ActiveScaffold and now I need to
> > internationalize the column descriptions.
> > I think the best form is create a method named human_description (ie:
> > Category.human_description :name) and create a method which overwrite the
> > ActiveScaffold to show it automatically if have.
> >
> > What you think?
> >
> > Thanks
> >
> > --
> > Regards,
> >
> > Gabriel Sobrinho
> > E-mail: gabriel.sobri...@gmail.com
> > Phone: +55 31 8775 8378
> >
> > Don't print this e-mail. The nature is thankful and your money also.
>
>
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com

G. Sobrinho

unread,
Jul 2, 2009, 1:07:05 PM7/2/09
to actives...@googlegroups.com
Thank you for applying this "plugin". Wiki need's update about that, I'm without time to change that.

If you can, update wiki also.



Thank you again Sergio

2009/7/2 Sergio Cambra .:: entreCables S.L. ::. <ser...@entrecables.com>



--
Regards,

Gabriel Sobrinho
E-mail: gabriel....@gmail.com
Reply all
Reply to author
Forward
0 new messages