Feature #12475

Lazy loading of translation files for faster startup

Added by Jean-Philippe Lang almost 5 years ago. Updated almost 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Code cleanup/refactoring
Target version:2.2.0
Resolution:Fixed

Related issues

Related to Redmine - Defect #12861: Internal Error 500 on "settings" Closed
Related to Redmine - Defect #12900: Template::Error (translation missing: en.date.formats.def... Needs feedback
Related to Redmine - Defect #13491: Update RedmineInstall about support of ruby-1.8.7 (or not... Closed
Related to Redmine - Defect #13520: Internal Error (incompatible character encodings: ASCII-8... Closed

Associated revisions

Revision 10843
Added by Jean-Philippe Lang about 5 years ago

Adds a custom i18n backend that lazily loads translations files.

Revision 10844
Added by Jean-Philippe Lang about 5 years ago

Cache languages names to avoid loading all translations files.

Revision 10846
Added by Jean-Philippe Lang about 5 years ago

Symbols can not be sorted with ruby1.8.

Revision 11673
Added by Toshi MARUYAMA over 4 years ago

add test to ensure language name is UTF-8 (#12475)

History

#1 Updated by Stefano Gargiulo almost 4 years ago

Is this really implemented?

I was using redmine in Italian (IT_it) locale but i was getting this error 500 on administrative user editing pages:

ActionView::Template::Error (can not load translations from /omissis/path/config/locales/*sr-CY.yml*: #<Errno::ENOENT: No such file or directory - /

Full trace:


Started GET "/users/13/edit" for 151.15.191.145 at 2014-01-05 04:18:34 +0100
Processing by UsersController#edit as HTML
  Parameters: {"id"=>"13"}
  Current user: stefano (id=1)
  Rendered users/_form.html.erb (3.5ms)
  Rendered users/_general.html.erb (4.1ms)
  Rendered common/_tabs.html.erb (5.0ms)
  Rendered users/edit.html.erb within layouts/admin (7.0ms)
Completed 500 Internal Server Error in 10.8ms

ActionView::Template::Error (can not load translations from /omissis/path/config/locales/sr-CY.yml: #<Errno::ENOENT: No such file or directory - / /omissis/path/config/locales/sr-CY.yml>):
    9:   <p><%= f.text_field :firstname, :required => true %></p>
    10:   <p><%= f.text_field :lastname, :required => true %></p>
    11:   <p><%= f.text_field :mail, :required => true %></p>
    12:   <p><%= f.select :language, lang_options_for_select %></p>
    13:   <% if Setting.openid? %>
    14:   <p><%= f.text_field :identity_url  %></p>
    15:   <% end %>
  lib/redmine/i18n.rb:152:in `init_translations'
  lib/redmine/i18n.rb:166:in `lookup'
  lib/redmine/i18n.rb:52:in `ll'
  lib/redmine/i18n.rb:96:in `block (2 levels) in languages_options'
  lib/redmine/i18n.rb:96:in `map'
  lib/redmine/i18n.rb:96:in `block in languages_options'
  lib/redmine/i18n.rb:95:in `languages_options'
  app/helpers/application_helper.rb:962:in `lang_options_for_select'
  app/views/users/_form.html.erb:12:in `_app_views_users__form_html_erb___1844358433978560630_70070849426320'
  app/views/users/_general.html.erb:2:in `block in _app_views_users__general_html_erb__2956019574731655906_70070848366580'
  app/helpers/application_helper.rb:977:in `labelled_form_for'
  app/views/users/_general.html.erb:1:in `_app_views_users__general_html_erb__2956019574731655906_70070848366580'
  app/views/common/_tabs.html.erb:24:in `block in _app_views_common__tabs_html_erb___2205524068201026269_70070848303940'
  app/views/common/_tabs.html.erb:23:in `each'
  app/views/common/_tabs.html.erb:23:in `_app_views_common__tabs_html_erb___2205524068201026269_70070848303940'
  app/helpers/application_helper.rb:272:in `render_tabs'
  app/views/users/edit.html.erb:9:in `_app_views_users_edit_html_erb___280756995300269414_44922720'

sr-CY is not a language that I was using in any way!!! And the only web browser that was browsing the redmine instance was mine in IT_it locale.

I removed the sr-CY.yml file and the error fixed, anyway this means that translation is not really lazy loaded (I'm using redmine 2.4.2 and ruby 1.9.3), contrary an error in a unused translation parsing is blocking for the used translation too!

#2 Updated by Toshi MARUYAMA almost 4 years ago

sr-CY.yml was removed by r4003.

#3 Updated by Stefano Gargiulo almost 4 years ago

I apologize it was my bad, i did a wrong redmine upgrade keeping the old files too!

Also available in: Atom PDF