
i18n and date_select exception
Reported by YavorIvanov | February 10th, 2009 @ 01:10 PM
When migrating a current project from GetText to i18n the following exception was thrown when using the date_select helper:
can't convert Symbol into String
Example:
When in your application you have set the I18n.locale to something different than "en" and you have the following simple code in your view:
<%= date_select("user_info", "birthdate") %>
You'll get the can't convert Symbol into String for the date_select helper. The problem can be rescued by giving the date_select helper order like this:
<%= date_select("user_info", "birthdate", :order => [:day,:month,:year]) %>
or by doing order in the yml file usually located at config/locales/your_lang.yml like this
date:
formats:
default: ""
long: ""
short: ""
order: [ :day, :month, :year ]
Comments and changes to this ticket
-
MvE July 7th, 2009 @ 01:31 PM
The :order work around nicely prevents the exception from being thrown.
In my environment (ruby 1.8.6, rails 2.3.2) the :month option results in a series of numbers (internal id's?) to be displayed, not the actual months. Do you know how I can correct this?
-
Ronald de Gunst August 8th, 2009 @ 11:02 PM
Also for ruby 1.8.7, rails 2.3.3 I get a series of numbers for :month
-
Ronald de Gunst August 8th, 2009 @ 11:56 PM
- Assigned user cleared.
This was caused by missing translations?
date_helper.rb returns 'translation missing: nl, date, month_names' for month_names[number]
config/locale/nl.yml exists with the monthnames.From the console:
I18n.l Date.today, :locale => :en => "2009-08-08" I18n.l Date.today, :locale => :nl I18n::MissingTranslationData: translation missing: nl, date, formats
Stupid, stupid: it has to be config/locales, not config/locale
Same cause for MvE?
-
MvE August 9th, 2009 @ 01:25 PM
- Assigned user set to Sven Fuchs
Folder was already named config/locales, so unfortunately I still have the problem. But thanks for the suggestion.
-
MvE August 9th, 2009 @ 02:06 PM
Problem is somewhere at my end.
When I start a clean rails 2.3.2 project and download an untouched fr.yml file, then the application displays dates correctly in English & French.
Somehow, I'm causing the problem with projects updated from pre rails 2.3.2. Or when I add in a large block of application specific messages from the yml in an older application.
Ensuring that spaces, rather than any hidden tab characters in the yml file, keeps the dreaded "syntax error on line x, col y" error message away during the load. Unfortunately, as soon as I get an error free load, the "can't convert Symbol into String" returns.
Does any one know of a 'yml' validator routine, that would help me see how I'm causing the problem?
-
rbaezam December 14th, 2009 @ 08:45 PM
- Assigned user cleared.
Hi, i had the same problem than you and i finally found a solution.
Make sure the name is the same in all places.
In my case, i was using the es_MX locale, but the yml file was named es.yml and the start of the file was "es-MX":
So i changed the file name to be es_MX.yml, the start of the file to be the same "es_MX:" and make sure the line in config/environment.rb was right (config.i18n.default_locale = :es_MX). Notice that all have an underscore.I hope that helps to you too.
-
mcansky January 19th, 2010 @ 11:25 AM
- Assigned user set to Sven Fuchs
hi,
same problem here, got numbers instead of months name,
no luck with the fixes described earlier, so wondering if there is any news around about it ? -
sharas January 20th, 2010 @ 05:10 PM
Seems, numbers are shown because helper can't find proper month names (maybe problem with defining formats?).
Anyway this is how I solved it (pay attention to YAML layout):
@@@ YAMLlt: date: order: [ :year, :month, :day ] formats: default: "%Y-%m-%d" short: "%b %d" long: "%B %d, %Y" day_names: [Sekmadienis, Pirmadienis, Antradienis, Trečiadienis, Ketvirtadienis, Penktadienis, Sekmadienis] abbr_day_names: [S, P, A, T, K, Pn, Š] month_names: [~, Sausis, Vasaris, Kovas, Balandis, Gegužė, Birželis, Liepa, Rugpjūtis, Rugsėjis, Spalis, Lapkritis, Gruodis] abbr_month_names: [~, Sau, Vas, Kov, Bal, Geg, Bir, Lie, Rugs, Rugp, Spa, Lap, Gruo]
P.S. I registered to lighthouseapp.com only to show solution. Not sure if you will ever see me here.
-
AaronGallagher February 11th, 2021 @ 11:48 AM
Light house and all project is fit for the advancement for the goals. Improvement of the nature and custom writings in the ambit for the turns. Elevation is piled for the rogues for the goodness for the moves for all people.
-
Rise Hluoluo August 7th, 2021 @ 10:06 AM
Walaupun begitu, pemain yang telah berumur 39 tahun tersbut di perkirakan sudah fit saat AC Milan melawan Cagliari di Serie A beberapa hari lalu.
Selama satu bulan tersebut, Ibrahimovic tertinggal sebanyak enam pertandingan untuk Coppa Italia yang di sebabkan oleh cidera betis yang ia alami. Terakhir kali ia bermain bersama tim AC Milan, saat timnya mendapatkan kemenangan dari Napoli dengan skokr akhir 3-1 di tanggal 22 november tahun lalu.
Pertandingan AC Milan melawan Napoli lalu tersebut, ia berhasil memberikan 2 gol kepada timnya. https://Ontrok.web.id Dengan pengorbanan yang harus ia tuai berupa cidera betis, yang membuatnya tidak dapat bertandinga selama 6 pertandingan di liga Italia.
Walaupun Zlatan Ibrahimovic harus absen dengan enam pertandingan terakhirnya di liga Italia, Tim AC Milan masih menjadi tim yang tidak terkalahkan. Dan timnya berhasil berada di psosisi pertama klasemen sementara untuk liga Italia.
-
-
-
gojec63917 May 29th, 2023 @ 09:37 PM
Using the website airslate.com/workflows/document/society. I was largely relieved. This is due to the exceptional service they provide.
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 ยป
Internationalization API for Ruby.
This library is used in Ruby on Rails but also suited for use in other contexts.