HoboFields::EnumStrings not translating when symbol is ":on"
Reported by Tim Griffin | May 14th, 2011 @ 11:41 AM
When an enumstring definition includes the symbol ":on", Hobo ignores the related translation key and shows the option as "On".
Sample definition (e.g. project.rb)
Region = HoboFields::Types::EnumString.for(:ab, :bc, :mb, :nb, :nl, :ns, :nt, :nu, :on, :pe, :qc, :sk, :yt, :other)
Sample Locale File:
project/regions: ab: "Alberta" bc: "British Columbia" mb: "Manitoba" nb: "New Brunswick" nl: "Newfoundland and Labrador" ns: "Nova Scotia" nt: "Northwest Territories" nu: "Nunavut" on: "Ontario" pe: "Prince Edward Island" qc: "Quebec" sk: "Saskatchewan" yt: "Yukon" other: "Other (Specify)"
Comments and changes to this ticket
-
Domizio Demichelis May 15th, 2011 @ 02:16 PM
- State changed from new to invalid
That's related with a yaml feature (or problem if you don't know it). "on" is a special word in the yaml world, like "true", "false", "yes" and "no" IIRC, translated to a boolean value.
If you don't quote it you are keying your hash with a true/false value, not with a "on" value. You have just to use quotes and yaml will understand it is a string and not as a boolean value.
The result is always "On" because hte key is not found so it is defaulted to the value in your declaration (:on) to_s titleized.
-
Tim Griffin May 16th, 2011 @ 05:50 PM
Ah-hah! Thank you, Domizio.
Yes, I changed my locale file to read
project/regions: ab: "Alberta" nt: "Northwest Territories" nu: "Nunavut" "on": "Ontario" pe: "Prince Edward Island"
and the select value correctly shows up as "Ontario" now.
Many thanks,
Tim -
Tim Griffin May 16th, 2011 @ 05:53 PM
I'll create a ticket for Owen to get this documented for EnumStrings.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป