Project

General

Profile

Actions

Defect #5608

closed

broken with i18n 0.4.0

Added by Chulki Lee over 14 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Category:
Translations
Target version:
Start date:
2010-05-28
Due date:
% Done:

100%

Estimated time:
Resolution:
Fixed
Affected version:

Description

  • Rails 2.3.5
  • Redmine: svn/branches/0.9-stable (r3742), production mode
  • Ruby: 1.8.7, Ruby Enterprise Edition
Processing WelcomeController#index (for ####### at 2010-05-28 11:21:46) [GET]
  Parameters: {"action"=>"index", "controller"=>"welcome"}
Rendering template within layouts/base
Rendering welcome/index

ActionView::TemplateError (missing interpolation argument in "%m/%{count}/%Y %I:%M %p" ({:object=>"2010-05-17 18:37:48 +0900"} given)) on line #22 of app/views/welcome/index.rhtml:
19:             <ul>
20:             <% for project in @projects %>
21:                     <li>
22:                     <%= link_to h(project.name), :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
23:                     <%= textilizable project.short_description, :project => project %>
24:                     </li>
25:             <% end %>

    /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/i18n-0.4.0/lib/i18n/backend/base.rb:177:in `interpolate_without_deprecated_syntax'
    /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/i18n-0.4.0/lib/i18n/backend/base.rb:48:in `translate'
    /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/i18n-0.4.0/lib/i18n.rb:152:in `t'
    /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/i18n-0.4.0/lib/i18n/backend/base.rb:61:in `localize'
    /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/i18n-0.4.0/lib/i18n.rb:231:in `l'
    lib/redmine/i18n.rb:48:in `format_time'

I'm not sure it's a redmine's bug - i18n 0.3.7 works. config.gem should be more specific.


Files

locales_update.rb (212 Bytes) locales_update.rb Jean-Baptiste Barth, 2010-09-02 12:48

Related issues

Related to Redmine - Feature #6428: Interim solution for i18n >= 0.4ClosedEric Davis2010-09-17

Actions
Related to Redmine - Defect #6461: Erro no template quando tento acessar vários locais do sistemaClosed2010-09-22

Actions
Related to Redmine - Defect #6733: Error 500 after changing Date Format or Time FormatClosed2010-10-24

Actions
Has duplicate Redmine - Defect #6314: Upgrade from 0.9.6 to 1.0.1 failsClosed2010-09-06

Actions
Blocks Redmine - Feature #5518: Graceful fallback for "missing translation" neededClosed2010-05-13

Actions
Actions #1

Updated by Chulki Lee over 14 years ago

Here is a patch for source:trunk/lib/redmine/i18n.rb

line 48

-      Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) : 
+      Setting.time_format.blank? ? l(local, :format => (include_date ? :default : :time)) :

It works with i18n 0.4.1

Actions #2

Updated by Martin Frost over 14 years ago

The same error will still occur when using format_date, and this patch results in "missing translation" errors.

Actions #3

Updated by Martin Frost over 14 years ago

A better solution would be to actually supply an interpolation variable, such as count.
There should probably be a better interpolation variable, but that's the first one I found, and it seems to work for me.

Here's a diff with what I made to make it work:

source:trunk/lib/redmine/i18n.rb

line 40:

-      Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format)
+      Setting.date_format.blank? ? ::I18n.l(date.to_date, :count => date.day) : date.strftime(Setting.date_format)

line 48:

-      Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) : 
+      Setting.time_format.blank? ? ::I18n.l(local, :count => local.day, :format => (include_date ? :default : :time)) : 

Actions #4

Updated by Jean-Baptiste Barth over 14 years ago

Just noticed the same bug, but there's also a depreciation warning about the way variables are passed to i18n :

The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.
/var/lib/gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:162:in `interpolate_without_deprecated_syntax'

Maybe both should be fixed the same time ?

Actions #5

Updated by Martin Frost over 14 years ago

Jean-Baptiste Barth wrote:

Just noticed the same bug, but there's also a depreciation warning about the way variables are passed to i18n : [...]

Maybe both should be fixed the same time ?

That sounds like a good idea.

Actions #6

Updated by Gregor Schmidt over 14 years ago

As far as I can tell, i18n 0.4.x is incompatible with Rails 2.3.5 - it could work with 2.3.6 though (http://github.com/svenfuchs/i18n/issues/issue/20). Furthermore it seems to be impossible to make Rails/Redmine ignore the newer gem and use the bundled version instead (http://stackoverflow.com/questions/2975532/have-rails-2-3-x-ignore-the-i18n-gem) - at least I could not find a working solution.

You should try to remove the i18n gem from your environment by using bundler or rvm.

The deprecation warnings should be tackled, once the update to Rails 2.3.6+ or 3.x is in progress.

Actions #7

Updated by Chris Collins over 14 years ago

This is actually because activesupport calls in the gem itself, and does so rather loosely.

It can be fixed by editing vendor/rails/activesupport/lib/active_support/vendor.rb and changing the: "gem 'i18n'..." line to include: ,"< 0.4.0".

This will prevent redmine's activesupport from pulling in the i18n 0.4 family which triggers this bug.

Actions #8

Updated by Jérémy Lal over 14 years ago

  • Assignee set to Eric Davis

Martin Frost wrote:

A better solution would be to actually supply an interpolation variable, such as count.
There should probably be a better interpolation variable, but that's the first one I found, and it seems to work for me.

Here's a diff with what I made to make it work:

source:trunk/lib/redmine/i18n.rb

I also got that bug, and Martin's solution works.
It would be great to apply that patch for 1.0.1

Jérémy

Actions #9

Updated by Piotr Mąsior over 14 years ago

Experienced this bug recently with passenger and only working solution is Martin's patch

Actions #10

Updated by Martin Frost over 14 years ago

Oh, and by the way, i18n 0.4.1 solved some other issues for me, so it would probably be a good idea to make redmine require that version and make it work.

0.4.1 has deprecated the {{key}} syntax as well. The new syntax is %{key}, so those changes will have to be made to all locale files.

Actions #11

Updated by Eric Davis over 14 years ago

Martin Frost wrote:

0.4.1 has deprecated the {{key}} syntax as well. The new syntax is %{key}, so those changes will have to be made to all locale files.

That's cute. Anyone up for writing a script to update all of the locale files?

Actions #12

Updated by Jean-Baptiste Barth over 14 years ago

  • Assignee changed from Eric Davis to Jean-Baptiste Barth

Eric Davis wrote:

That's cute. Anyone up for writing a script to update all of the locale files?

I can. Do you want it before 1.0.1 ? It may be a bit risky to change the gem version 7 days before release...

Anyway, I wonder why they chose this %{} syntax, and not the ruby interpolation one #{}. We used to have two diverging syntaxes, and now we have... two new ones + (bonus!) an important rewrite. Anyone knows ?

Actions #13

Updated by Martin Frost over 14 years ago

Jean-Baptiste Barth wrote:

Eric Davis wrote:

That's cute. Anyone up for writing a script to update all of the locale files?

I can. Do you want it before 1.0.1 ? It may be a bit risky to change the gem version 7 days before release...

Anyway, I wonder why they chose this %{} syntax, and not the ruby interpolation one #{}. We used to have two diverging syntaxes, and now we have... two new ones + (bonus!) an important rewrite. Anyone knows ?

It might be that if they were to use #{}, then people would believe they could input arbitrary ruby code, and they want to make a distinction from that. This is just a wild guess on my part though.

Actions #14

Updated by Jean-Baptiste Barth over 14 years ago

Martin Frost wrote:

It might be that if they were to use #{}, then people would believe they could input arbitrary ruby code, and they want to make a distinction from that. This is just a wild guess on my part though.

Sounds like a good reason :)

Actions #15

Updated by Christof Spies over 14 years ago

Workaround:
rake VERSION=2.3.5 rails:freeze:gems
vim vendor/rails/activesupport/lib/active_support/vendor.rb
#24
gem 'i18n', '< 0.4.0'

Actions #16

Updated by Christof Spies over 14 years ago

better:
gem 'i18n', '>= 0.1.3', '< 0.4.0'

Actions #17

Updated by John Lovell over 14 years ago

Thanks Christof, this fixed the issue for me.

Actions #18

Updated by Jean-Baptiste Barth over 14 years ago

  • File locales_update.rb locales_update.rb added
  • Status changed from New to 7
  • % Done changed from 0 to 30
  • Affected version (unused) changed from 0.9.4 to devel
  • Affected version deleted (0.9.4)

Eric: here's a script for updating locale files with the new syntax. Seems it works well, but if some people want to test it it would be fine (especially people with non-ascii locales..).

But it's not sufficient: there are other deprecation warnings because we have some "%d"s in our locales for date formatting.

I'll take a look at that and assign the issue back to you with patches when everything is ready so that you can decide when we move.

Actions #19

Updated by Felix Schäfer over 14 years ago

For anybody interested: I have a working patch in #6428 to make redmine work with i18n-0.4, big thanks to Martin Frost for the inspiration.

Actions #20

Updated by Eric Davis about 14 years ago

  • Category set to Translations
  • Status changed from 7 to Resolved
  • Target version set to 1.0.2
  • % Done changed from 30 to 100
  • Resolution set to Fixed

I've added Felix's patch from #6428 to work around Rails and i18n 4.x. This should at least let Redmine run, with quite a few warnings that something is wrong.

When we get Redmine 1.1.0 ready, we will upgrade to the latest Rails 2.3.x or Rails 3.x so this patch can be removed then.

Actions #21

Updated by Eric Davis about 14 years ago

  • Status changed from Resolved to Closed

Merged into 1.0-stable

Actions #22

Updated by Mark Suman about 14 years ago

Eric Davis wrote:

Merged into 1.0-stable

Thank you. I pulled the change you merged and it fixed the issue for me.

Actions #23

Updated by Sean Murphy about 14 years ago

I just created a Ubuntu 10.10 server, installed redmine via apt-get which shows redmine as the latest stable 1.0 version but I still ran into this error. Using Martin's suggestion in #note-3 did the trick though.

Actions #24

Updated by dye jarhoo about 10 years ago

Hello coming back from 2014,
using debian Squeeze latest repo
This patch NOT FIX on redmine package(1.0.1-2)
BTW, using this patch with webrick it logs

 warn "The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.\nDowngrade your i18n gem to 0.3.7 (everything above must be deinstalled) to remove this warning, see http://www.redmine.org/issues/5608 for more information." 

FYI:
NOT FIX means:

NOT FIX only appears @hostname/settings

rails 2.3.5
ruby 1.8.7
i18n 0.6.11
acitvesupport-3.2.19(which depend on i18n >0.6

EDIT: for formate

Actions #25

Updated by Holger Just about 10 years ago

@dye jarhoo: Redmine 1.0 is not supported here anymore. You could open a bug on Debian's issue tracker but I doubt it will ever be fixed given that Squeeze is oldstable already and the next version after that is about to be released soon. Thus, you should just update to a newer version of Redmine.

Actions

Also available in: Atom PDF