Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:51:38+00:00 2026-05-27T05:51:38+00:00

I googled around but didn’t find an answer – even if I guess it

  • 0

I googled around but didn’t find an answer – even if I guess it isn’t tricky!

I’d like to localize a sentense that icludes date and time parameter. I want to pass it a complete datetime.

de_txt.yml

  de:
    article:
      will_be_published_at: 'Wartet auf Veröffentlichung am %a %e. %b %Y um %H:%M Uhr'

My function with d is out of the database, field type is datetime
(second line is the one of my problem)

  def icon_article_will_be_published_at(d)
    alt = t('article.will_be_published_at', d)
    image_tag("#{root_url}images/famfamfam/icons/date_next.png", :title => alt, :alt => alt, :class => "icon")
  end

more about d

d.inspect # => Sat, 03 Dec 2011 14:07:00 CET +01:00

I can’t figure it out and would appreciate help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:51:38+00:00Added an answer on May 27, 2026 at 5:51 am

    For this, you will need the I18n#l method, not the translate method.
    It’s a bit tricky, because you need a separate time format in the translations file (de.yml). This is one way to do it (adjust as necessary):

    In config/locales/de.yml:

    de:
      time:
        formats:
          article_published_at: 'Wartet auf Veröffentlichung am %a %e. %b %Y um %H:%M Uhr'
    

    Testing it in the console:

    I18n.locale = :de
    
    I18n.l Time.now, :format => :article_published_at
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I googled it around but didn't find it. I remember there was a way
I've googled around but couldn't find a working MongoDB viewer or data browser. An
I've googled around everywhere, but cannot find much for rendering strings to textures and
I have been searching around using Google but I can't find an answer to
I've googled around and found some answers but I didn't get any of them
I have searched/Googled around but I'm struggling with the following problem. I am building
Possible Duplicate: Why are two different concepts both called “heap”? I've googled around, but
I've checked Wikipedia and googled but I still can't wrap my mind around how
I've had a look around SO and Google but can't find a definite and
The same question might have been asked but I didn't find any solutions available

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.