Localize doesn't work

Hello,

for some reason I18n.localize(Time.now, :format => :default) [and
l(Time.now, :format => :default)] returns an empty string although
t(’.text’) does work.

Anyone knows what’s wrong with my I18n?

I checked t(‘time.formats.defaults’), it’s existing:
time:
formats:
default: “%a, %d %b %Y %H:%M:%S %z”
short: “%d %b %H:%M”
long: “%B %d, %Y %H:%M”
am: “am”
pm: “pm”

Anything else that could cause an empty string as result?

What does t(“time.formats”) give you?

t(“time.formats”) returns:
default%A, %e. %B %Y, %H:%M Uhrtime%H:%Mlong%A, %e. %B %Y, %H:%M
Uhrshort%e. %B, %H:%M Uhr

t(“time.formats.default”) returns:
%A, %e. %B %Y, %H:%M Uhr

It’s German so don’t get confused :slight_smile:

Sharagoz – wrote:

Where are you getting the empty string from I18n.localize? Are you
getting it in the console too?

Mind posting the whole translation file, or at least the top part
including the number localizations?

Console:

I18n.t(“time.formats.default”)
I18n.t(“time.formats.default”)
=> “%a, %d %b %Y %H:%M:%S %z”

I18n.l(Time.now, :formats => :default)
I18n.l(Time.now, :formats => :default)
=> “Tue, 23 Feb 2010 22:10:22 Mitteleuropäische Zeit”

Translation file:
en-US:
number:
# Used in number_with_delimiter()
# These are also the defaults for ‘currency’, ‘percentage’,
‘precision’, and ‘human’
format:
# Sets the separator between the units, for more precision (e.g.
1.0 / 2.0 == 0.5)
separator: “.”
# Delimets thousands (e.g. 1,000,000 is a million) (always in
groups of three)
delimiter: “,”
# Number of decimals, behind the separator (the number 1 with a
precision of 2 gives: 1.00)
precision: 3

time:
formats:
default: “%a, %d %b %Y %H:%M:%S %z”
short: “%d %b %H:%M”
long: “%B %d, %Y %H:%M”
am: “am”
pm: “pm”

but:
<%= I18n.l(Time.now, :formats => :default) %>
still returns nothing.

Where are you getting the empty string from I18n.localize? Are you
getting it in the console too?

Mind posting the whole translation file, or at least the top part
including the number localizations?

Heinz S. wrote:

I18n.localize(Time.now, :format => :default)
returns an empty string although
t(’.text’) does work.

Hi Heinz,

I’m having the same problem. Have you found a solution yet? Does anybody
have an idea? I’m using Rails 2.3.5

Thanks for any hints,
Sebastian

No, unfortunately not. Anyone else an idea?