Defect #5608

broken with i18n 0.4.0

Added by Chulki Lee over 1 year ago. Updated about 1 year ago.

Status:Closed Start date:2010-05-28
Priority:Normal Due date:
Assignee:Jean-Baptiste Barth % Done:

100%

Category:Translations
Target version:1.0.2
Affected version:devel Resolution:Fixed

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.

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


Related issues

related to Defect #6733: Error 500 after changing Date Format or Time Format Closed 2010-10-24
related to Defect #6461: Erro no template quando tento acessar vários locais do si... Closed 2010-09-22
related to Feature #6428: Interim solution for i18n >= 0.4 Closed 2010-09-17
duplicated by Defect #6314: Upgrade from 0.9.6 to 1.0.1 fails Closed 2010-09-06
blocks Feature #5518: Graceful fallback for "missing translation" needed Closed 2010-05-13

Associated revisions

Revision 4183
Added by Eric Davis over 1 year ago

Workaround for i18n 0.4.x with the old style syntax. #6428 #5608

This will also silance the whole trace with the deprecation warning.

Contributed by Felix Schäfer

History

Updated by Chulki Lee over 1 year 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

Updated by Martin Frost over 1 year ago

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

Updated by Martin Frost over 1 year 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)) : 

Updated by Jean-Baptiste Barth over 1 year 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 ?

Updated by Martin Frost over 1 year 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.

Updated by Gregor Schmidt over 1 year 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.

Updated by Chris Collins over 1 year 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.

Updated by Jérémy Lal over 1 year 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

Updated by Piotr Mąsior over 1 year ago

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

Updated by Martin Frost over 1 year 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.

Updated by Eric Davis over 1 year 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?

Updated by Jean-Baptiste Barth over 1 year 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 ?

Updated by Martin Frost over 1 year 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.

Updated by Jean-Baptiste Barth over 1 year 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 :)

Updated by Christof Spies over 1 year 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'

Updated by Christof Spies over 1 year ago

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

Updated by John Lovell over 1 year ago

Thanks Christof, this fixed the issue for me.

Updated by Jean-Baptiste Barth over 1 year ago

  • File locales_update.rb added
  • Status changed from New to Assigned
  • % Done changed from 0 to 30
  • Affected version changed from 0.9.4 to devel

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.

Updated by Felix Schäfer over 1 year 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.

Updated by Eric Davis over 1 year ago

  • Category set to Translations
  • Status changed from Assigned 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.

Updated by Eric Davis over 1 year ago

  • Status changed from Resolved to Closed

Merged into 1.0-stable

Updated by Mark Suman over 1 year ago

Eric Davis wrote:

Merged into 1.0-stable

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

Updated by Sean Murphy about 1 year 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.

Also available in: Atom PDF