I18n retuns empty string?

Hello,

does any one know why:
<%= I18n.l Time.now %>
returns an empty string?

But it works when I run it on the console:
I18n.l Time.now
=> "Mon, 29 Mar 2010 18:38:32 +0100"

I can't think of anything that could cause that problem and Google
didn't help... any help would be highly appreciated!

No one?

Nope, it works as expected for me on
Rails 2.3.5 + ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]

Can you create a reproducible test case?

How could a test case help me? Output of the console shows already that
there's something messed up:

I18n.locale

I18n.locale
=> "DE-de"

I18n.l(Time.now, :formats => :default)

I18n.l(Time.now, :formats => :default)
=> "Sun, 04 Apr 2010 12:49:37 +0100"

I18n.l(Time.now, :formats => :short)

I18n.l(Time.now, :formats => :short)
=> "Sun, 04 Apr 2010 12:52:23 +0100"

I18n.l(Date.today, :formats => :default)

I18n.l(Date.today, :formats => :default)
=> "2010-04-04"

I18n.l(Date.today, :formats => :long)

I18n.l(Date.today, :formats => :long)
=> "2010-04-04"

Locale is "DE-de" which is German but Time and Date is still being
displayed in the English format. Furtermore it doesn't make a difference
if I change the formats argument which is not how it's meant to be as
well.

There musst be really something screwed up but I have no idea what that
could be.... really frustrating.

By the way: It doesn't matter if I use Ruby 1.8.6 or 1.9.1.

In the posting above I'm using 1.8.6 and this is 1.9.1:
Loading development environment (Rails 2.3.5)
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:
Gem::Dependency#version_requirements is deprecated and will be removed
on or after August 2010. Use #requirement

I18n.locale

I18n.locale
=> :"en-US"

I18n.l Time.now

I18n.l Time.now
=> "Sun, 04 Apr 2010 12:55:11 +0100"

I18n.locale = "de-DE"

I18n.locale = "de-DE"
=> "de-DE"

I18n.l Time.now

I18n.l Time.now
=> "Sun, 04 Apr 2010 12:55:23 +0100"

Again, for you -- not for me. So reducing the problem to the smallest
possible test case that other people can try is one way to get help.

In creating that test case you may discover the cause (some plugin
or gem conflict, or who knows what).

FWIW,

But what exactly would you want to test in that test case?

By "test case" here I mean the smallest possible application that
reproduces the "empty string" error you're describing.

Well, I created a new application - no plugins or anything and it
worked.

By the way I'm using globalize2 for model translation. Could that be the
problem?

Presumably it could -- so add it to your new app and see :slight_smile:

I figured out that there's a problem with the .yml file. When I remove
my yml file everything works just fine but when I add my .yml file with
my customized language strings like:
de-DE:
  time:
    formats:
      default: "%A, %e. %B %Y, %H:%M Uhr"

It returns an empty string. I just can't find anything wrong with that
default: ?

Heinz Strunk wrote:

I figured out that there's a problem with the .yml file. When I remove
my yml file everything works just fine but when I add my .yml file with
my customized language strings like:
de-DE:
  time:
    formats:
      default: "%A, %e. %B %Y, %H:%M Uhr"

It returns an empty string. I just can't find anything wrong with that
default: ?

Got it! I had an outdated yml file. %e isn't supported anymore and
therefore returns nothing. Just had to replace the %e with a %d.