Commit c4d4eae3f9b66c0216c929ddcaccf42ab5231f13
1 parent
91eaaa66
Exists in
master
and in
9 other branches
Remove interpolation from translatable strings
Also added test/unit/i18n_test.rb which will warn us if any others pop up.
Showing
13 changed files
with
42 additions
and
15 deletions
Show diff stats
app/controllers/my_profile/profile_editor_controller.rb
... | ... | @@ -109,7 +109,7 @@ class ProfileEditorController < MyProfileController |
109 | 109 | profile = environment.profiles.find(params[:id]) |
110 | 110 | if profile.disable |
111 | 111 | profile.save |
112 | - session[:notice] = _("The profile '#{profile.name}' was deactivated.") | |
112 | + session[:notice] = _("The profile '%s' was deactivated.") % profile.name | |
113 | 113 | else |
114 | 114 | session[:notice] = _('Could not deactivate profile.') |
115 | 115 | end |
... | ... | @@ -123,7 +123,7 @@ class ProfileEditorController < MyProfileController |
123 | 123 | profile = environment.profiles.find(params[:id]) |
124 | 124 | |
125 | 125 | if profile.enable |
126 | - session[:notice] = _("The profile '#{profile.name}' was activated.") | |
126 | + session[:notice] = _("The profile '%s' was activated.") % profile.name | |
127 | 127 | else |
128 | 128 | session[:notice] = _('Could not activate the profile.') |
129 | 129 | end | ... | ... |
app/views/content_viewer/article_versions.html.erb
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | <li> |
13 | 13 | <%= radio_button_tag 'v1', v.version, false, :onclick => 'versionInputClicked(this)' %> |
14 | 14 | <%= radio_button_tag 'v2', v.version, false, :onclick => 'versionInputClicked(this)' %> |
15 | - <%= link_to(_("Version #{v.version}"), @page.url.merge(:version => v.version)) %> | |
15 | + <%= link_to(_("Version %s") % v.version, @page.url.merge(:version => v.version)) %> | |
16 | 16 | <%= @page.version == v.version ? _('(current)') : '' %> |
17 | 17 | <span class='updated-by'><%= _('by %{author}') % {:author => link_to(@page.author_name(v.version), @page.author_url(v.version))} %></span> |
18 | 18 | <span class='updated-on'><%= show_time(v.updated_at) %></span> | ... | ... |
app/views/profile_roles/destroy.html.erb
app/views/profile_roles/edit.html.erb
app/views/role/edit.html.erb
app/views/shared/_content_item.html.erb
... | ... | @@ -6,6 +6,6 @@ |
6 | 6 | <span class="item-description"> |
7 | 7 | <%= link_to(content.name, content.url) %> |
8 | 8 | </span> |
9 | - <span class="item-date"><%= _("Published at: #{show_date(content.updated_at)}") %></span> | |
9 | + <span class="item-date"><%= _("Published at: %s") % show_date(content.updated_at) %></span> | |
10 | 10 | </div> |
11 | 11 | </div> | ... | ... |
lib/tasks/gettext.rake
... | ... | @@ -60,6 +60,8 @@ task :updatepo do |
60 | 60 | |
61 | 61 | puts 'Extracting strings from source. This may take a while ...' |
62 | 62 | |
63 | + # XXX this list is duplicated in test/unit/i18n_test.rb; if you change it | |
64 | + # here, please also update it there. | |
63 | 65 | files_to_translate = [ |
64 | 66 | "{app,lib}/**/*.{rb,rhtml,erb}", |
65 | 67 | 'config/initializers/*.rb', | ... | ... |
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
... | ... | @@ -29,7 +29,7 @@ class OauthClientPluginPublicController < PublicController |
29 | 29 | if user_provider.enabled? && provider.enabled? |
30 | 30 | session[:user] = user.id |
31 | 31 | else |
32 | - session[:notice] = _("Can't login with #{provider.name}") | |
32 | + session[:notice] = _("Can't login with %s") % provider.name | |
33 | 33 | end |
34 | 34 | |
35 | 35 | redirect_to :controller => :account, :action => :login | ... | ... |
plugins/oauth_provider/views/doorkeeper/authorizations/new.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | <main role="main"> |
8 | 8 | <p class="h4"> |
9 | - <%= _('Authorize %s to use your account?' % "<strong class=\"text-info\">#{@pre_auth.client.name}</strong>") %> | |
9 | + <%= _('Authorize %s to use your account?') % "<strong class=\"text-info\">#{@pre_auth.client.name}</strong>" %> | |
10 | 10 | </p> |
11 | 11 | |
12 | 12 | <% if @pre_auth.scopes %> | ... | ... |
plugins/sub_organizations/lib/related_organizations_block.rb
... | ... | @@ -24,7 +24,7 @@ class RelatedOrganizationsBlock < ProfileListBlock |
24 | 24 | end |
25 | 25 | |
26 | 26 | def help |
27 | - _("This block displays #{display_type[:title]} organizations of this organization") | |
27 | + _("This block displays %s organizations of this organization") % display_type[:title] | |
28 | 28 | end |
29 | 29 | |
30 | 30 | def profiles | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
1 | 1 | <% extend SubOrganizationsPlugin::SearchHelper %> |
2 | 2 | <div class="related-organizations-list-block"> |
3 | 3 | |
4 | - <h1><%= _("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | |
4 | + <h1><%= _("%s's sub-%s") % [profile.name, organization_type.pluralize] %></h1> | |
5 | 5 | <ul> |
6 | 6 | <% organizations.each do |organization| %> |
7 | 7 | <li class="related-organizations-item"> |
... | ... | @@ -53,7 +53,7 @@ |
53 | 53 | |
54 | 54 | <% button_bar(:class => "related-organizations-button-bar") do %> |
55 | 55 | <%= button :back, c_('Go back'), { :controller => 'profile' } %> |
56 | - <%= button :add, _("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
56 | + <%= button :add, _("Add a new %s") % organization_type, :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
57 | 57 | |
58 | 58 | <% if !@full %> |
59 | 59 | <%= button :more, c_('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_related_organizations.html.erb
1 | 1 | <div class="common-profile-list-block"> |
2 | - <h1><%= _("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | |
2 | + <h1><%= _("%s's sub-%s") % [profile.name, organization_type.pluralize] %></h1> | |
3 | 3 | |
4 | 4 | <ul class='profile-list'> |
5 | 5 | <% organizations.each do |organization| %> |
... | ... | @@ -7,11 +7,11 @@ |
7 | 7 | <% end %> |
8 | 8 | </ul> |
9 | 9 | <% if organizations.length == 0 %> |
10 | - <li><%= _("There are no sub-#{organization_type.pluralize} yet. " ) %></li> | |
10 | + <li><%= _("There are no sub-%s yet.") % organization_type.pluralize %></li> | |
11 | 11 | <% end %> |
12 | 12 | <% button_bar(:class => "related-organizations-button-bar") do %> |
13 | 13 | <%= button :back, c_('Go back'), { :controller => 'profile' } %> |
14 | - <%= button :add, _("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
14 | + <%= button :add, _("Add a new %s") % organization_type, :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
15 | 15 | |
16 | 16 | <% if !@full %> |
17 | 17 | <%= button :more, c_('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | ... | ... |
... | ... | @@ -0,0 +1,25 @@ |
1 | +require_relative "../test_helper" | |
2 | + | |
3 | +class I18nTest < ActiveSupport::TestCase | |
4 | + | |
5 | + # XXX this duplicates the list from lib/tasks/gettext.rake | |
6 | + files_to_translate = [ | |
7 | + "{app,lib}/**/*.{rb,rhtml,erb}", | |
8 | + 'config/initializers/*.rb', | |
9 | + 'public/*.html.erb', | |
10 | + 'public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}', | |
11 | + ].map { |pattern| Dir.glob(pattern) }.flatten | |
12 | + | |
13 | + plugins_files_to_translate = Dir.glob("plugins/**/*.{rb,html.erb}") | |
14 | + | |
15 | + (files_to_translate + plugins_files_to_translate).each do |f| | |
16 | + test "translation marks in #{f}" do | |
17 | + lines = File.readlines(f).select do |line| | |
18 | + line =~ /\b_\(["'][^)]*#\{/ | |
19 | + end | |
20 | + assert lines == [], "found interpolation in translatable strings:\n" + lines.join("\n") | |
21 | + end | |
22 | + end | |
23 | + | |
24 | +end | |
25 | + | ... | ... |