#12 new
YavorIvanov

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

    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

    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

    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

    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

    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

    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

    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

    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):
    @@@ YAML

    lt:
      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

    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

    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.

  • Mira
  • gojec63917

    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.

  • lily lily

    lily lily June 21st, 2023 @ 05:59 AM

    The error message "can't convert Symbol into String" typically occurs when there is an issue with the format or type of the parameters being passed to a method. In the case of the date_select helper in Rails, it seems to be related to the order of the date gacha life components.

  • Mikasa Ackerman

    Mikasa Ackerman June 30th, 2023 @ 09:08 AM

    Have you found the solution to this problem? fnf

  • taylorgodiva28

    taylorgodiva28 July 10th, 2023 @ 06:06 AM

    I wonder if the clean rails 2.3.2 project has been successful? Geometry Dash Scratch

  • David Mathew

    David Mathew July 11th, 2023 @ 05:53 PM

    I was also facing the same problem named "can't convert Symbol into String". Glad found help here. Now I can do migration of website The Leather City with peace.

  • johndavidd

    johndavidd July 25th, 2023 @ 11:09 AM

    The exception "can't convert Symbol into String" in the context of migrating a project Amanda The Adventurer from GetText to i18n and using the date_select helper is likely caused by a mismatch in the way date formats are handled.

  • Kelsey Radley

    Kelsey Radley August 31st, 2023 @ 06:04 AM

    Unfortunately, I still have the issue because the folder was previously called config/locales. However, I appreciate the suggestion. Rainbow Friends

  • rosy23dam

    rosy23dam September 26th, 2023 @ 06:42 AM

    Prepare for an unforgettable gaming experience with only up . Climb to new heights and share your triumphs with players from all over the world. In this world, your achievements are celebrated, and your skills are put to the test.

  • Emma Brown

    Emma Brown September 27th, 2023 @ 05:54 AM

    Your content is excellent and fascinating, and as a result, I now know more helpful stuff. I'll continue to read your posts if you keep them engaging. mapquest directions

  • larryellison

    larryellison October 2nd, 2023 @ 05:37 AM

    The :order work around nicely prevents the exception from being thrown but I still cannot handle the geometry dash bloodbath successfully

  • williamliz

    williamliz October 2nd, 2023 @ 10:39 AM

    There are many solutions for the error of not being able to convert Symbols to Strings, but I haven't found a solution as optimal as five nights at freddy's 4

  • elijahnelson

    elijahnelson October 16th, 2023 @ 11:42 AM

    I enjoy how the information is presented in the article in a clear and mapquest directions pertinent manner.

  • zetisda

    zetisda November 3rd, 2023 @ 09:55 AM

    Top-tier players and teams compete spacebar clicker in high-stakes tournaments for substantial cash prizes and global recognition.

  • priscillawheuer

    priscillawheuer December 29th, 2023 @ 11:25 AM

    Dummy Vapes redefine vaping bliss with their innovative flavors. Indulge in a sensory journey of exquisite taste and clouds, crafted to elevate your vaping experience to new heights of satisfaction.

  • lilycollins

    lilycollins January 2nd, 2024 @ 08:07 AM

    Pass :orderoption to date_select:
    Ruby
    <%= date_select("user_info", "birthdate", :order => [:day, :month, :year]) %> slope

  • Kelsey Radley

    Kelsey Radley January 11th, 2024 @ 08:56 AM

    The error of not being able to convert symbols to strings has a lot of fixes, but I haven't come across an tunnel rush ideal one.

  • Harry Calvin

    Harry Calvin January 11th, 2024 @ 09:46 AM

    Thanks for sharing your experience with migrating from GetText to i18n. The solution you provided for handling the "can't convert Symbol into String" exception in the date_select helper is really helpful. I'll make sure to keep it in mind when dealing with similar issues.
    Digital Trebuchet

  • Maru Kari

    Maru Kari January 15th, 2024 @ 02:57 AM

    This is one of the best articles I have ever read on this blog. Thank you for sharing very interesting information. Suika game

  • Maru Kari

    Maru Kari January 15th, 2024 @ 02:58 AM

    I really like the information you share. I learned a lot of new and useful knowledge from your post.

  • Isabella

    Isabella January 16th, 2024 @ 07:30 AM

    For those seeking to enhance their digital images with advanced AI technology, a Remini Download offers an intuitive solution to improve photo quality significantly.

    Website

  • kalyl

    kalyl January 23rd, 2024 @ 08:18 AM

    Ensure that you are passing the correct parameters among us to the date_select helper. Symbols are often used as keys, so make sure that symbols are not mistakenly being used as values.

  • Jack Reacher
  • PedroEffler

    PedroEffler March 14th, 2024 @ 08:25 AM

    The depth of research in prodentim this blog is truly commendable. Well done!

  • amnaseo
  • amnaseo
  • amnaseo
  • amnaseo
  • amnaseo
  • amnaseo
  • amnaseo
  • amnaseo

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.

New-ticket Create new ticket

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.

Pages