That seems like a reasonable solutiony to me.
On Feb 23, 2012 2:41 PM, "Ignacio Huerta" <[email protected]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I've been digging into this and I have found that right now the
> enum_string translations is done within hobo_fields, and that makes
> translations only work on first load in production mode.
>
> Maybe we can move translations to the tag library? I made a small test
> with the input tag and it worked nicely in development and production
> mode:
>
> <def tag="input" for="HoboFields::Types::EnumString" attrs="labels,
> titleize, first-option, first-value"><%
>  labels ||= {}
>  labels = HashWithIndifferentAccess.new(labels)
>  titleize = true if titleize.nil?
>
>  # I18N: First we need to find the column name searching in the
> content_columns
>  for column in model.content_columns.*.name
>    if model.attr_type(column) == this_type
>      options = this_type.values.map {|v|
>        [
>
> I18n.t("activerecord.attributes.#{model.to_s.downcase}/#{column}s.#{v}",
>          :default => titleize ? v.titleize : v),
>        v]}
>    end
>  end
>  %>
>  <select name="#{param_name_for_this}" merge-attrs>
>    <option value="#{first_value}"
> unless="&first_option.nil?"><first-option/></option>
>    <%= options_for_select(options, this) %>
>  </select>
> </def>
>
>
> Now you can add translations to your app.**.yml like this:
>
>  activerecord:
>    attributes:
>      order/pickup_points:
>        hotel: "Hotel"
>        office: "Oficina"
>        airport: "Aeropuerto"
>
> Do you think this is a good solution? If you want I can test it a bit
> more and make a pull request :).
>
> Regards,
> Ignacio
>
> El 23/02/12 16:40, Ignacio Huerta escribió:
> > Thank you very much to both of you.
> >
> > I'm afraid the workaround didn't work for me. I got this error:
> >
> > uninitialized constant OrdersController::Region
> >
> > I'm going to try to take a look at the Hobo code and see what I
> > can do. By the way, I created an ticket about this in lighthouse:
> > we have reached ticket number 1000!
> >
> >
> https://hobo.lighthouseapp.com/projects/8324-hobo/tickets/1000-i18n-support-switching-locales-with-enum_string
> >
> >  Regards, Ignacio
> >
> > El 23/02/12 10:25, Bryan Larsen escribió:
> >>> Current enum_string implementation doesn't consider locale
> >>> switching.
> >
> >> This is not a coincidence.  Hobo's i18n mechanism was written by
> >>  people who actually use it: Spiralis and Domizio, primarily.
> >> The only exception is the enum_string localization, which I
> >> wrote because we needed to finish 1.3 and get it out the door,
> >> instead of writing it because I needed it for one of my own
> >> websites.
> >
> >> So if somebody who actually creates multi-lingual websites wants
> >> to take a crack at fixing this problem properly, that would be
> >> appreciated.
> >
> >> Bryan
> >
> >
>
> - --
> Ignacio Huerta Arteche
> http://www.ihuerta.net
> Teléfono: 0034 645 70 77 35
> Email realizado con software libre
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk9Gll0ACgkQBPlUJ6RHaOTPsgCdFKaWwla4YyTeq4xNjG48tMf2
> hd0AnRWzO9nD09lo6hvRgCoq0q9JJFhQ
> =gIP+
> -----END PGP SIGNATURE-----
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to