diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 29 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 103 | ||||
-rw-r--r-- | app/helpers/link_to_helper.rb | 6 | ||||
-rw-r--r-- | app/models/public_body.rb | 17 | ||||
-rw-r--r-- | app/views/admin_public_body/_locale_selector.rhtml | 10 | ||||
-rw-r--r-- | app/views/comment/_comment_form.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/_before_body_end.rhtml | 16 | ||||
-rw-r--r-- | app/views/general/_credits.rhtml | 5 | ||||
-rw-r--r-- | app/views/general/_locale_switcher.rhtml | 12 | ||||
-rw-r--r-- | app/views/general/_orglink.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/custom_css.rhtml | 1 | ||||
-rw-r--r-- | app/views/general/frontpage.rhtml | 25 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 72 | ||||
-rw-r--r-- | app/views/help/about.es.rhtml | 10 | ||||
-rw-r--r-- | app/views/layouts/admin.rhtml | 17 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 96 | ||||
-rw-r--r-- | app/views/public_body/show.rhtml | 56 | ||||
-rw-r--r-- | app/views/request/list.rhtml | 10 |
19 files changed, 289 insertions, 223 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9382e077f..91754e2ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,11 +12,28 @@ class ApplicationController < ActionController::Base # Standard headers, footers and navigation for whole site layout "default" - # set locale + include FastGettext::Translation # make functions like _, n_, N_ etc available) before_filter :set_gettext_locale + + # scrub sensitive parameters from the logs + filter_parameter_logging :password + + + def set_gettext_locale + requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] + session[:locale] = FastGettext.set_locale(requested_locale) + end + # scrub sensitive parameters from the logs filter_parameter_logging :password + helper_method :site_name, :locale_from_params + def site_name + # XXX should come from database: + site_name = "WhatDoTheyKnow" + return site_name + end + # Help work out which request causes RAM spike. # http://www.codeweblog.com/rails-to-monitor-the-process-of-memory-leaks-skills/ # This shows the memory use increase of the Ruby process due to the request. @@ -131,6 +148,16 @@ class ApplicationController < ActionController::Base f.write(content) end end + + # get the local locale + def locale_from_params(*args) + if params[:show_locale] + params[:show_locale] + else + I18n.locale.to_s + end + end + private # Check the user is logged in diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 21e715424..cf28208a0 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -22,22 +22,7 @@ class GeneralController < ApplicationController def frontpage behavior_cache do # This is too slow - #@popular_bodies = PublicBody.find(:all, :select => "*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", :order => "c desc", :limit => 32) - - # Just hardcode some popular authorities for now - # ('tgq', 'atbra' is for debugging on Francis's development environment) - @popular_bodies = PublicBody.find(:all, :conditions => ["url_name in ( - 'bbc', - 'dwp', - 'dh', - 'snh', - 'royal_mail_group', - 'mod', - 'kent_county_council', - 'wirral_borough_council' - /* , 'tgq', 'atbra' */ - )"]).sort_by { |pb| pb.url_name }.reverse # just an order that looks better - + @popular_bodies = PublicBody.find(:all, :select => "*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", :order => "c desc", :limit => 32) # Get some successful requests # begin query = 'variety:response (status:successful OR status:partially_successful)' @@ -168,5 +153,11 @@ class GeneralController < ApplicationController render :text => "awake\n" end + def custom_css + @locale = self.locale_from_params() + render(:layout => false, :content_type => 'text/css') + end + + end diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 17eba911f..cf64046ea 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -16,87 +16,96 @@ class PublicBodyController < ApplicationController return end - @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise "None found" if @public_body.nil? # XXX proper 404 + @locale = self.locale_from_params() + PublicBody.with_locale(@locale) do + @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) + raise "None found" if @public_body.nil? # XXX proper 404 - # If found by historic name, redirect to new name - redirect_to show_public_body_url(:url_name => @public_body.url_name) if - @public_body.url_name != params[:url_name] + # If found by historic name, redirect to new name + redirect_to show_public_body_url(:url_name => @public_body.url_name) if + @public_body.url_name != params[:url_name] - set_last_body(@public_body) + set_last_body(@public_body) - top_url = main_url("/") - @searched_to_send_request = false - referrer = request.env['HTTP_REFERER'] - if !referrer.nil? && referrer.match(%r{^#{top_url}search/.*/bodies$}) - @searched_to_send_request = true - end + top_url = main_url("/") + @searched_to_send_request = false + referrer = request.env['HTTP_REFERER'] + if !referrer.nil? && referrer.match(%r{^#{top_url}search/.*/bodies$}) + @searched_to_send_request = true + end - # Use search query for this so can collapse and paginate easily - # XXX really should just use SQL query here rather than Xapian. - begin - @xapian_requests = perform_search([InfoRequestEvent], 'requested_from:' + @public_body.url_name, 'newest', 'request_collapse') - if (@page > 1) - @page_desc = " (page " + @page.to_s + ")" - else - @page_desc = "" + # Use search query for this so can collapse and paginate easily + # XXX really should just use SQL query here rather than Xapian. + begin + @xapian_requests = perform_search([InfoRequestEvent], 'requested_from:' + @public_body.url_name, 'newest', 'request_collapse') + if (@page > 1) + @page_desc = " (page " + @page.to_s + ")" + else + @page_desc = "" + end + rescue + @xapian_requests = nil end - rescue - @xapian_requests = nil - end - @track_thing = TrackThing.create_track_for_public_body(@public_body) - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + @track_thing = TrackThing.create_track_for_public_body(@public_body) + @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] - respond_to do |format| - format.html { @has_json = true } - format.json { render :json => @public_body.json_for_api } + respond_to do |format| + format.html { @has_json = true } + format.json { render :json => @public_body.json_for_api } + end end end def view_email @public_bodies = PublicBody.find(:all, :conditions => [ "url_name = ?", params[:url_name] ]) @public_body = @public_bodies[0] - - if params[:submitted_view_email] - if verify_recaptcha - flash.discard(:error) - render :template => "public_body/view_email" - return + PublicBody.with_locale(self.locale_from_params()) do + if params[:submitted_view_email] + if verify_recaptcha + flash.discard(:error) + render :template => "public_body/view_email" + return + end + flash.now[:error] = "There was an error with the words you entered, please try again." end - flash.now[:error] = "There was an error with the words you entered, please try again." + render :template => "public_body/view_email_captcha" end - render :template => "public_body/view_email_captcha" end def list # XXX move some of these tag SQL queries into has_tag_string.rb @tag = params[:tag] + @locale = self.locale_from_params() + locale_condition = 'public_body_translations.locale = ?' if @tag.nil? @tag = "all" - conditions = [] + conditions = [locale_condition, @locale] elsif @tag == 'other' category_list = PublicBodyCategories::CATEGORIES.map{|c| "'"+c+"'"}.join(",") - conditions = ['(select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id + conditions = [locale_condition + ' AND (select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id and has_tag_string_tags.model = \'PublicBody\' - and has_tag_string_tags.name in (' + category_list + ')) = 0'] + and has_tag_string_tags.name in (' + category_list + ')) = 0', @locale] elsif @tag.size == 1 @tag.upcase! - conditions = ['first_letter = ?', @tag] + conditions = [locale_condition + ' AND public_body_translations.first_letter = ?', @locale, @tag] elsif @tag.include?(":") name, value = HasTagString::HasTagStringTag.split_tag_into_name_value(@tag) - conditions = ['(select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id + conditions = [locale_condition + ' AND (select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id and has_tag_string_tags.model = \'PublicBody\' - and has_tag_string_tags.name = ? and has_tag_string_tags.value = ?) > 0', name, value] + and has_tag_string_tags.name = ? and has_tag_string_tags.value = ?) > 0', @locale, name, value] else - conditions = ['(select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id + conditions = [locale_condition + ' AND (select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id and has_tag_string_tags.model = \'PublicBody\' - and has_tag_string_tags.name = ?) > 0', @tag] + and has_tag_string_tags.name = ?) > 0', @locale, @tag] end - @public_bodies = PublicBody.paginate( - :order => "public_bodies.name", :page => params[:page], :per_page => 1000, # fit all councils on one page - :conditions => conditions + PublicBody.with_locale(@locale) do + @public_bodies = PublicBody.paginate( + :order => "public_body_translations.name", :page => params[:page], :per_page => 1000, # fit all councils on one page + :conditions => conditions, + :joins => :translations ) + end if @tag.size == 1 @description = "beginning with '" + @tag + "'" else diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 93151ecfe..85913b12e 100644 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -197,6 +197,12 @@ module LinkToHelper return date.strftime("%Y").strip end + #I18n locale switcher + + def locale_switcher(locale, params) + params['locale'] = locale + return url_for(params) + end end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 446ac2334..51d6ea914 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -44,6 +44,9 @@ class PublicBody < ActiveRecord::Base has_tag_string + translates :name, :short_name, :request_email, :url_name, :notes + translates :first_letter, :publication_scheme + # like find_by_url_name but also search historic url_name if none found def self.find_by_url_name_with_historic(name) found = PublicBody.find_all_by_url_name(name) @@ -67,7 +70,8 @@ class PublicBody < ActiveRecord::Base # Set the first letter, which is used for faster queries before_save(:set_first_letter) def set_first_letter - self.first_letter = self.name[0,1].upcase + # we use a regex to ensure it works with utf-8/multi-byte + self.first_letter = self.name.scan(/./mu)[0].upcase end def validate @@ -166,16 +170,21 @@ class PublicBody < ActiveRecord::Base # When name or short name is changed, also change the url name def short_name=(short_name) - write_attribute(:short_name, short_name) + globalize.write(self.class.locale || I18n.locale, :short_name, short_name) + self[:short_name] = short_name + globalize.save_translations! self.update_url_name end def name=(name) - write_attribute(:name, name) + globalize.write(self.class.locale || I18n.locale, :name, name) + self[:name] = name + globalize.save_translations! self.update_url_name end + def update_url_name url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body') - write_attribute(:url_name, url_name) + self.url_name = url_name end # Return the short name if present, or else long name def short_or_long_name diff --git a/app/views/admin_public_body/_locale_selector.rhtml b/app/views/admin_public_body/_locale_selector.rhtml new file mode 100644 index 000000000..5ef79f2df --- /dev/null +++ b/app/views/admin_public_body/_locale_selector.rhtml @@ -0,0 +1,10 @@ +<div id="locale_switcher"> +<%= _('Edit language version:') %> +<% for possible_locale in @locales %> + <% if possible_locale == @locale %> + <%= possible_locale %> + <% else %> + <a href="?show_locale=<%=possible_locale%>"><%= possible_locale %></a> + <% end %> +<% end %> +</div> diff --git a/app/views/comment/_comment_form.rhtml b/app/views/comment/_comment_form.rhtml index aae0c4638..f943cf8ad 100644 --- a/app/views/comment/_comment_form.rhtml +++ b/app/views/comment/_comment_form.rhtml @@ -6,7 +6,7 @@ <% if !TrackThing.find_by_existing_track(@user, track_thing) && (!@user || @info_request.user != @user) %> <p> - <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] ? true : false %> <label for="subscribe_to_request">Email me future updates to this request</label> + <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] ? true : false %> <label for="subscribe_to_request"><%= _('Email me future updates to this request') %></label> </p> <% end %> diff --git a/app/views/general/_before_body_end.rhtml b/app/views/general/_before_body_end.rhtml new file mode 100644 index 000000000..8d7ebeeb5 --- /dev/null +++ b/app/views/general/_before_body_end.rhtml @@ -0,0 +1,16 @@ +<% if MySociety::Config.get("DOMAIN", '127.0.0.1:3000') == 'www.whatdotheyknow.com' %> +<!-- Piwik --> +<script type="text/javascript"> +var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.mysociety.org/" : "http://piwik.mysociety.org/"); +document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); +</script><script type="text/javascript"> +try { +var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4); +piwikTracker.trackPageView(); +piwikTracker.enableLinkTracking(); +} catch( err ) {} +</script><noscript><p><img src="http://piwik.mysociety.org/piwik.php?idsite=4" style="border:0" alt=""/></p></noscript> +<!-- End Piwik Tag --> +<% end %> + + diff --git a/app/views/general/_credits.rhtml b/app/views/general/_credits.rhtml new file mode 100644 index 000000000..a2f7a9cb2 --- /dev/null +++ b/app/views/general/_credits.rhtml @@ -0,0 +1,5 @@ +| + Built by <a href="http://www.mysociety.org/">mySociety</a> ... + <a href="/help/credits#helpus">and you</a> + | + Dedicated to <a href="http://mk.ucant.org/archives/000129.html">Chris Lightfoot</a> diff --git a/app/views/general/_locale_switcher.rhtml b/app/views/general/_locale_switcher.rhtml new file mode 100644 index 000000000..4f01a4d13 --- /dev/null +++ b/app/views/general/_locale_switcher.rhtml @@ -0,0 +1,12 @@ + <% if FastGettext.default_available_locales.length > 1 %> + <div id="user_locale_switcher"> + Language: + <% for possible_locale in FastGettext.default_available_locales %> + <% if possible_locale == I18n.locale.to_s %> + <%= possible_locale %> + <% else %> + <a href="<%= locale_switcher(possible_locale, params) %>"><%= possible_locale %></a> + <% end %> + <% end %> + </div> + <% end %> diff --git a/app/views/general/_orglink.rhtml b/app/views/general/_orglink.rhtml new file mode 100644 index 000000000..551b18646 --- /dev/null +++ b/app/views/general/_orglink.rhtml @@ -0,0 +1,2 @@ +<%-# Put the link to your organisation here, or leave blank -%> +<a href="http://www.mysociety.org">a site by mysociety.org</a> diff --git a/app/views/general/custom_css.rhtml b/app/views/general/custom_css.rhtml new file mode 100644 index 000000000..0def82ed0 --- /dev/null +++ b/app/views/general/custom_css.rhtml @@ -0,0 +1 @@ +// this should be overridden in a local "theme" plugin diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index 51bf55e34..276ac70a7 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -1,25 +1,28 @@ <% view_cache :ttl => 5.minutes do %> <div id="frontpage_search"> - <h1>Make or explore Freedom of Information requests</h1> + <h1><%= _('Make or explore Freedom of Information requests') %></h1> <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %> <p> - First, type in the <strong>name of the UK public authority</strong> you'd + <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d <br>like information from. <strong>By law, they have to respond</strong> - (<a href="/help/about">why?</a>). + (<a href="%s">why?</a>).') % help_about_url %> <br> <br> <%= text_field_tag 'query', params[:query], { :size => 30 } %> <%= hidden_field_tag 'bodies', 1 %> - <%= submit_tag "Search" %> + <%= submit_tag _('Search') %> <br> - e.g. <%=link_to 'Liverpool', search_url('liverpool', 'bodies')%>, <%=link_to 'MRSA', search_url('mrsa', 'bodies')%>, <%=link_to 'Treasury', search_url('treasury', 'bodies')%> + <%= _('e.g.') %> + <% @popular_bodies.each_with_index do |body, i| %> + <%=link_to body.name, search_url(body.name, 'bodies')%><% if i < 2 %>, <% else %>. <% break %><% end %> + <% end %> <br> <br> - OR, <strong>search</strong> for information others have requested using WhatDoTheyKnow.com + <%= _('OR, <strong>search</strong> for information others have requested using {{site_name}}', :site_name => site_name) %> </p> <% end %> </div> @@ -27,15 +30,15 @@ <div id="frontpage_examples"> <% if @popular_bodies.size > 0 %> <div id="examples_0"> - <ul> + <ul> <% for popular_body in @popular_bodies %> <li><%=public_body_link(popular_body)%> - <%=h popular_body.info_requests.count%> requests + <%= n_('%d request', '%d requests', popular_body.info_requests.count) % popular_body.info_requests.count %> </li> <% end%> </ul> <p><strong> - <%= link_to "More authorities...", list_public_bodies_default %> + <%= link_to _('More authorities...'), list_public_bodies_default %> </strong></p> </div> <% end %> @@ -45,11 +48,11 @@ <ul> <% for event in @successful_request_events %> <li><%=link_to h(excerpt(event.info_request.title, "", 30)), request_url(event.info_request)%> - <%=h time_ago_in_words(event.described_at).gsub("about ", "") %> ago + <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> </li> <% end %> </ul> - <p><strong><a href="/list/successful">More successful requests...</a></strong></p> + <p><strong><%=link_to _('More successful requests...'), request_list_successful_url %></strong></p> </div> <% end %> </div> diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index 29ce73d5c..876d54270 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -1,21 +1,20 @@ <% @show_tips = @xapian_requests.nil? || (@total_hits == 0) %> <% if @query.nil? %> - <% @title = "Search Freedom of Information requests, public authorities and users" %> + <% @title = _("Search Freedom of Information requests, public authorities and users") %> <h1><%=@title%></h1> <% elsif @total_hits == 0 %> - <% @title = "Nothing found for '" + h(@query) + "'" %> + <%= _("Nothing found for '{{search_terms}}'", :search_terms => h(@query)) %> <% else %> - <% @title = "Results page " + @page.to_s %> + <% @title = _("Results page {{page_number}}", :page_number => @page.to_s) %> <% end%> <% @include_request_link_in_authority_listing = true %> <% if @bodies && (@page == 1 || @xapian_bodies.results.size > 0) %> <div id="stepwise_instructions"> - <p><strong>Next, select the public authority you'd like to make the request from.</strong></p> - <p>Can't find it? <%= link_to "Browse all", list_public_bodies_default %> or - <a href="/help/requesting#missing_body">ask us to add it</a>.</p> + <p><strong><%=_("Next, select the public authority you'd like to make the request from.") %></strong></p> + <p><% _('Can\'t find it? <a href="%s">Browse all</a> or <a href="%s">ask us to add it</a>.') % [list_public_bodies_default, "#{help_requesting_path}#missing_body"] %></p> <p> </div> <% end %> @@ -27,30 +26,31 @@ <% if @bodies %> <%= hidden_field_tag 'bodies', 1 %> <% end %> - <%= submit_tag "Search" %> + <%= submit_tag _("Search") %> <% if not @show_tips %> - <a href="/search">Advanced search tips</a> + <%= link_to _('Advanced search tips'), search_redirect_path %> <% end %> </p> <% end %> <% if !@query.nil? %> <p> - <%=link_to_unless @sortby == 'relevant', "Show most relevant results first", search_url(@query, 'relevant') %> + <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url(@query, 'relevant') %> | - <%=link_to_unless @sortby == 'newest', "Newest results first", search_url(@query, 'newest') %> + <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url(@query, 'newest') %> <% if @sortby == 'described' %> - | Recently described results first + | <%= _('Recently described results first') %> <% end %> </p> <% end %> <% if @bodies && !@query.nil? && @xapian_bodies.results.size == 0 && @page == 1 %> - <h1>No public authorities found</h1> + <h1><%= _('No public authorities found') %></h1> <% if @spelling_correction %> - <p id="did_you_mean">Did you mean: <%= search_link(@spelling_correction, @postfix) %></p> + <p id="did_you_mean"><%= _('Did you mean: {{correction}}', + :correction => search_link(@spelling_correction, @postfix)) %></p> <% end %> - <p><%=link_to "Browse all", list_public_bodies_default %> or <a href="/help/requesting#missing_body">ask us to add one</a>.</p> + <p><%= _('<a href="%s">Browse all</a> or <a href="%s">ask us to add one</a>.') % [list_public_bodies_default, help_requesting_path + '#missing_body'] %></p> <% end %> <% if @total_hits == 0 %> @@ -59,7 +59,7 @@ <% if not @query.nil? %> <% if @spelling_correction %> - <p id="did_you_mean">Did you mean: <%= search_link(@spelling_correction, @postfix) %></p> + <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction, @postfix)) %></p> <% end %> <% if (!@bodies || @xapian_requests.results.size == 0) && @track_thing && (@xapian_bodies.results.size > 0 || @xapian_users.results.size > 0 || @total_hits == 0)%> @@ -67,7 +67,7 @@ <% end %> <% if @xapian_bodies.results.size > 0 %> - <h1><%= "Public authorities " + ((@page-1)*@bodies_per_page+1).to_s + "-" + [@page*@bodies_per_page, @xapian_bodies.matches_estimated].min.to_s + " of " + @xapian_bodies.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + <h1><%= _('Public authorities {{start_count}} to {{end_count}} of {{total_count}} for {{user_search_query}}', :start_count => ((@page-1)*@bodies_per_page+1).to_s, :end_count => [@page*@bodies_per_page, @xapian_bodies.matches_estimated].min.to_s, :total_count => @xapian_bodies.matches_estimated.to_s, :user_search_query => h(@query)) %></h1> <% for result in @xapian_bodies.results %> <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %> @@ -77,7 +77,7 @@ <% end %> <% if @xapian_users.results.size > 0 %> - <h1><%= "People " + ((@page-1)*@users_per_page+1).to_s + "-" + [@page*@users_per_page, @xapian_users.matches_estimated].min.to_s + " of " + @xapian_users.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + <h1><%= _("People {{start_count}} to {{end_count}} of {{total_count}} for {{user_search_query}}", :start_count => ((@page-1)*@users_per_page+1).to_s, :end_count => [@page*@users_per_page, @xapian_users.matches_estimated].min.to_s, :total_count => @xapian_users.matches_estimated.to_s, :user_search_query => h(@query)) %></h1> <% for result in @xapian_users.results %> <%= render :partial => 'user/user_listing_single', :locals => { :display_user => result[:model] } %> @@ -87,7 +87,7 @@ <% end %> <% if @xapian_requests.results.size > 0 %> - <h1><%= "FOI requests " + ((@page-1)*@requests_per_page+1).to_s + "-" + [@page*@requests_per_page, @xapian_requests.matches_estimated].min.to_s + " of " + @xapian_requests.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + <h1><%= _("FOI requests {{start_count}} to {{end_count}} of {{total_count}} for {{user_search_query}}", :start_count => ((@page-1)*@requests_per_page+1).to_s, :end_count => [@page*@requests_per_page, @xapian_requests.matches_estimated].min.to_s, :total_count => @xapian_requests.matches_estimated.to_s, :user_search_query => h(@query)) %></h1> <% if @track_thing %> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %> @@ -106,27 +106,27 @@ <% end %> <% if @show_tips %> - <h2>Advanced search tips</h2> + <h2><%= _("Advanced search tips")%></h2> <ul> - <li>Enter words that you want to find separated by spaces, e.g. <strong><%=search_link('climbing lane')%></strong></li> - <li>Use OR (in capital letters) where you don't mind which word, e.g. <strong><%=search_link('commons OR lords')%></strong> - <li>Use quotes when you want to find an exact phrase, e.g. <strong><%=search_link('"Liverpool City Council"')%></strong> - <li><strong>status:</strong> to select based on the status or historical status of the request, see the <a href="#statuses">table of statuses</a> below. - <li><strong>variety:</strong> to select type of thing to search for, see the <a href="#varieties">table of varieties</a> below. - <li><strong><%=search_link('requested_from:home_office')%></strong> to search requests from the <%= link_to "Home Office", show_public_body_url(:url_name => 'home_office') %>, typing the name as in the URL. - <li><strong><%=search_link('requested_by:julian_todd')%></strong> to search requests made by <%= link_to "Julian Todd", show_user_url(:url_name => 'julian_todd') %>, typing the name as in the URL. - <li><strong><%=search_link('commented_by:tony_bowden')%></strong> to search annotations made by <%= link_to "Tony Bowden", show_user_url(:url_name => 'tony_bowden') %>, typing the name as in the URL. - <li><strong>request:</strong> to restrict to a specific request, typing the title as in the URL. - <li><strong><%=search_link('filetype:pdf')%></strong> to find all responses with PDF attachments. Or try these: <%= IncomingMessage.get_all_file_extentions%>. - <li>Type <strong><%=search_link('01/01/2008..14/01/2008')%></strong> to only show things that happened in the first two weeks of January. - <li><strong><%=search_link('tag:charity')%></strong> to find all public bodies or requests with a given tag. You can include multiple tags, - and tag values, e.g. <%=search_link('tag:openlylocal AND tag:financial_transaction:335633')%>. Note that by default any of the tags - can be present, you have to put AND explicitly if you only want results them all present. - <li>Read about <a href="http://www.xapian.org/docs/queryparser.html">advanced search operators</a>, such as proximity and wildcards. + <li><%= _("Enter words that you want to find separated by spaces, e.g. <strong>climbing lane</strong>") %></li> + <li><%= _('Use OR (in capital letters) where you don\'t mind which word, e.g. <strong><code>commons OR lords</code></strong>') %> + <li><%= _('Use quotes when you want to find an exact phrase, e.g. <strong><code>"Liverpool City Council"</code></strong>') %></li> + <li><%= _('<strong><code>status:</code></strong> to select based on the status or historical status of the request, see the <a href="%s">table of statuses</a> below.') % "#statuses" %></li> + <li><%= _('<strong><code>variety:</code></strong> to select type of thing to search for, see the <a href="%s">table of varieties</a> below.') % "#varieties" %></li> + <li><%= _('<strong><code>requested_from:home_office</code></strong> to search requests from the Home Office, typing the name as in the URL.')%></li> + <li><%= _('<strong><code>requested_by:julian_todd</code></strong> to search requests made by Julian Todd, typing the name as in the URL.') %></li> + <li><%= _('<strong><code>commented_by:tony_bowden</code></strong> to search annotations made by Tony Bowden, typing the name as in the URL.')%></li> + <li><%= _('<strong><code>request:</code></strong> to restrict to a specific request, typing the title as in the URL.')%> + <li><%= _('<strong><code>filetype:pdf</code></strong> to find all responses with PDF attachments. Or try these: <code>{{list_of_file_extensions}}</code>', :list_of_file_extensions => IncomingMessage.get_all_file_extentions)%></li> + <li><%= _('Type <strong><code>01/01/2008..14/01/2008</code></strong> to only show things that happened in the first two weeks of January.')%></li> + <li><%= _('<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, + and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags + can be present, you have to put <code>AND</code> explicitly if you only want results them all present.')%></li> + <li><%= _('Read about <a href="%s">advanced search operators</a>, such as proximity and wildcards.') % "http://www.xapian.org/docs/queryparser.html" %></li> </ul> - <h2 id="statuses">Table of statuses</h2> - + <h2 id="statuses"><%= _('Table of statuses') %></h2> + <h3>XXX this should be automatically generated</h3> <table class="status_table"> <tr><td><strong><%=search_link('status:waiting_response')%></strong></td><td> Waiting for the public authority to reply </td></tr> <tr><td><strong><%=search_link('status:not_held')%></strong></td><td> The public authority does not have the information requested </td></tr> diff --git a/app/views/help/about.es.rhtml b/app/views/help/about.es.rhtml new file mode 100644 index 000000000..721a582aa --- /dev/null +++ b/app/views/help/about.es.rhtml @@ -0,0 +1,10 @@ +<% @title = "Sobre" %> + +<%= render :partial => 'sidebar' %> + +<h1>¡Bonjiorno amis!</h1> + +<p>Esta sito tu aidare a faire los requesti a la governmenti Seblano</p> + +<div id="hash_link_padding"></div> + diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml index 426a01cf5..a209715e1 100644 --- a/app/views/layouts/admin.rhtml +++ b/app/views/layouts/admin.rhtml @@ -9,17 +9,18 @@ <p> <strong><%= link_to 'WhatDoTheyKnow', main_url('/') %> admin:</strong> - <%= link_to 'Summary', admin_url('') %> - | <%= link_to 'Timeline', admin_url('timeline') %> - | <%= link_to 'Stats', admin_url('stats') %> - | <%= link_to 'Debug', admin_url('debug') %> + <%= link_to 'Summary', admin_general_index_path %> + | <%= link_to 'Timeline', admin_timeline_path %> + | <%= link_to 'Stats', admin_stats_path %> + | <%= link_to 'Debug', admin_debug_path %> | <%= link_to 'Wiki', "https://secure.mysociety.org/intranet/ProductionSites/WhatDoTheyKnow/WebHome" %> <strong>View:</strong> - <%= link_to 'Authorities', admin_url('body/list') %> - | <%= link_to 'Requests', admin_url('request/list') %> - | <%= link_to 'Users', admin_url('user/list') %> - | <%= link_to 'Tracks', admin_url('track/list') %> + <%= link_to 'Authorities', admin_body_list_path %> + | <%= link_to 'Requests', admin_request_list_path %> + | <%= link_to 'Users', admin_user_list_path %> + | <%= link_to 'Tracks', admin_track_list_path %> </p> + <%= render :partial => 'general/locale_switcher' %> <% if flash[:error] %> <p id="error"><%= flash[:error] %></p> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index 606203f06..be302103a 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -1,5 +1,5 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html lang="en-gb"> +<html lang="<%= I18n.locale %>"> <head> <script type="text/javascript" src="/jslib/spell/spellChecker.js"></script> @@ -12,9 +12,9 @@ <title> <% if @title %> - <%=@title%> - WhatDoTheyKnow + <%=@title%> - <%= site_name %> <% else %> - WhatDoTheyKnow - make and browse Freedom of Information (FOI) requests + <%= site_name %> - <%= _('Make and browse Freedom of Information (FOI) requests') %> <% end %> </title> @@ -23,7 +23,12 @@ <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %> <!--[if LT IE 7]> <style type="text/css">@import url("/stylesheets/ie6.css");</style> - <![endif]--> + <![endif]--> + <!--[if LT IE 7]> + <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style> + <![endif]--> + <%= stylesheet_link_tag 'main-custom', :title => "Main", :rel => "stylesheet" %> + <link href="http://127.0.0.1:3000/custom.css" media="screen" rel="stylesheet" type="text/css"> <% if @feed_autodetect %> <% for feed in @feed_autodetect %> @@ -68,33 +73,7 @@ =begin <div id="everypage" class="jshide"> <p style="float:right"><a href="#top" onclick="$.cookie('seen_foi2', 1, { expires: 7, path: '/' }); $('#everypage').hide('slow'); return false;">Close</a></p> - <h2>Blimey. It looks like the Internets won – <small>a message from WhatDoTheyKnow</small></h2> - <p>Sorry to interrupt, but we thought you’d like to know that <strong>you won</strong>! - <p>On the 16th of May 2008 the High Court ruled that MPs’ expenses must be published under the Freedom of Information Act. - - <p>Tomorrow, MPs <strong>were</strong> going to vote on changing the law to keep their expenses secret after all, - just before publication was due and after spending nearly a million of your pounds and seven months - compiling the data. - - <p>However, after a <strong>tremendous response</strong> from you, with over 7,000 members - on our Facebook group, 4,000 messages sent to MPs, help from - - <a href="http://twitter.com/stephenfry/statuses/1136046150">Stephen Fry</a>, and a helpful - <a href="http://www.publications.parliament.uk/pa/ld200809/ldselect/ldmerit/16/1603.htm">4th Report of the House of Lords - Merits of Statutory Instruments Committee</a>, - it appears that the vote has been cancelled – - <a href="http://www.guardian.co.uk/politics/2009/jan/21/mps-expenses">Guardian</a>, - <a href="http://www.timesonline.co.uk/tol/news/politics/article5559704.ece">Times</a>, - <a href="http://news.bbc.co.uk/1/hi/uk_politics/7842402.stm">BBC</a>. - - <p>As President Obama said in his inauguration speech: <em>“And - those of us who manage the public’s dollars will be held to account – to - spend wisely, reform bad habits, and do our business in the light of day – - - because only then can we restore the vital trust between a people and their - government.”</em></p> - - <p>Read <a href="http://www.mysociety.org/2009/01/21/blimey-it-looks-like-the-internets-won/">our victory blog post</a>. :-) + [ message goes here ] <p style="text-align: right"><a href="#top" onclick="$.cookie('seen_foi2', 1, { expires: 7, path: '/' }); $('#everypage').hide('slow'); return false;">Close</a></p> </div> =end @@ -104,41 +83,45 @@ </div> <div id="header"> <h1> - <a href="/">WhatDoTheyKnow?</a> + <%= link_to site_name, frontpage_url %> </h1> <div id="tagline"> - Make and explore Freedom of Information requests + <%= _('Make and explore Freedom of Information requests') %> </div> + <%= render :partial => 'general/locale_switcher' %> + </div> - <div id="mysoclogo"> - <a href="http://www.mysociety.org">a site by mysociety.org</a> + <div id="orglogo"> + <%= render :partial => 'general/orglink' %> </div> + <div id="navigation_search"> <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "navigation_search_form"}) do %> <p> <%= text_field_tag 'query', params[:query], { :size => 40, :id => "navigation_search_query" } %> - <%= submit_tag "Search" %> + <%= submit_tag _("Search") %> </p> <% end %> </div> <div id="topnav"> <ul id="navigation"> - <li><%= link_to "Make request", frontpage_url %></li> - <li><%= link_to "View requests", request_list_url(:view => 'successful') %></li> - <li><%= link_to "View authorities", list_public_bodies_default %></li> + <li><%= link_to _("Make request"), frontpage_url %></li> + <li><%= link_to _("View requests"), request_list_successful_url %></li> + <li><%= link_to _("View authorities"), list_public_bodies_default %></li> <% if @user %> - <li><%=link_to "My requests", user_url(@user) %></li> + <li><%=link_to _("My requests"), user_url(@user) %></li> <% end %> - <li><%= link_to "Read blog", blog_url %></li> - <li><%= link_to "Help", about_url %></li> + <li><%= link_to _("Read blog"), blog_url %></li> + <li><%= link_to _("Help"), help_about_url %></li> </ul> <% if not (controller.action_name == 'signin' or controller.action_name == 'signup') %> <div id="logged_in_bar"> <% if @user %> - Hello, <%=h(@user.name)%>! - (<%= link_to "Sign out", signout_url(:r => request.request_uri) %>) + <%= _('Hello, {{username}}!', :username => h(@user.name))%> + (<%= link_to _("Sign out"), signout_url(:r => request.request_uri) %>) <% else %> - Hello! (<%= link_to "Sign in or sign up", signin_url(:r => request.request_uri) %>) + <%= _('Hello!') %> + (<%= link_to _("Sign in or sign up"), signin_url(:r => request.request_uri) %>) <% end %> </div> <% end %> @@ -161,28 +144,11 @@ </div> <div id="footer"> - <a href="/help/contact">Contact WhatDoTheyKnow</a> - | - Built by <a href="http://www.mysociety.org/">mySociety</a> ... - <a href="/help/credits#helpus">and you</a> - | - Dedicated to <a href="http://mk.ucant.org/archives/000129.html">Chris Lightfoot</a> + <%= link_to _("Contact {{site_name}}", :site_name => site_name), help_contact_url %> + <%= render :partial => 'general/credits' %> </div> -<% if MySociety::Config.get("DOMAIN", '127.0.0.1:3000') == 'www.whatdotheyknow.com' %> -<!-- Piwik --> -<script type="text/javascript"> -var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.mysociety.org/" : "http://piwik.mysociety.org/"); -document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); -</script><script type="text/javascript"> -try { -var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4); -piwikTracker.trackPageView(); -piwikTracker.enableLinkTracking(); -} catch( err ) {} -</script><noscript><p><img src="http://piwik.mysociety.org/piwik.php?idsite=4" style="border:0" alt=""/></p></noscript> -<!-- End Piwik Tag --> -<% end %> + <%= render :partial => 'general/before_body_end' %> </body> </html> diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml index c1deea762..8b56d68c0 100644 --- a/app/views/public_body/show.rhtml +++ b/app/views/public_body/show.rhtml @@ -1,33 +1,34 @@ <% @title = h(@public_body.name) + " - view and make Freedom of Information requests" %> <div id="request_sidebar"> - <h2>Track this authority</h2> + <h2><%= _('Track this authority')%></h2> <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %> - <h2>More about this authority</h2> + <h2><%= _('More about this authority')%></h2> <% if !@public_body.calculated_home_page.nil? %> - <%= link_to "Home page of authority", @public_body.calculated_home_page %><br> + <%= link_to _('Home page of authority'), @public_body.calculated_home_page %><br> <% end %> <% if !@public_body.publication_scheme.empty? %> - <%= link_to "Publication scheme", @public_body.publication_scheme %><br> + <%= link_to _('Publication scheme'), @public_body.publication_scheme %><br> <% end %> <% if @public_body.has_tag?("charity") %> <% for tag_value in @public_body.get_tag_values("charity") %> + XXX UK-specific <% if tag_value.match(/^SC/) %> - <%= link_to "Charity registration", "http://www.oscr.org.uk/CharityIndexDetails.aspx?id=" + tag_value %><br> + <%= link_to _('Charity registration'), "http://www.oscr.org.uk/CharityIndexDetails.aspx?id=" + tag_value %><br> <% else %> - <%= link_to "Charity registration", "http://www.charity-commission.gov.uk/SHOWCHARITY/RegisterOfCharities/CharityFramework.aspx?RegisteredCharityNumber=" + tag_value %><br> + <%= link_to _('Charity registration'), "http://www.charity-commission.gov.uk/SHOWCHARITY/RegisterOfCharities/CharityFramework.aspx?RegisteredCharityNumber=" + tag_value %><br> <% end %> <% end %> <% end %> - <%= link_to "View FOI email address", view_public_body_email_url(@public_body.url_name) %><br> + <%= link_to _('View FOI email address'), view_public_body_email_url(@public_body.url_name) %><br> </div> <h1><%=h(@public_body.name)%></h1> <p class="subtitle"> -<%=@public_body.type_of_authority(true)%> in the UK<% if not @public_body.short_name.empty? %>, also called <%= h(@public_body.short_name) %><% end %> +<%=@public_body.type_of_authority(true)%><% if not @public_body.short_name.empty? %>, <%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name))%><% end %> <% if !@user.nil? && @user.admin_page_links? %> -(<%= link_to "admin", public_body_admin_url(@public_body) %>) +(<%= link_to _("admin"), public_body_admin_url(@public_body) %>) <% end %> </p> @@ -36,51 +37,48 @@ <% end %> <% if @public_body.eir_only? %> - <p>You can only request information about the environment from this authority.</p> + <p><%= _('You can only request information about the environment from this authority.')%></p> <% end %> <div id="stepwise_make_request"> <strong> <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %> - <% make = 'Make' %> - <% if @searched_to_send_request %> - Next, - <% make = 'make' %> - <% end %> <% if @public_body.eir_only? %> - <%= link_to make + " a new Environmental Information request", new_request_to_body_url(:url_name => @public_body.url_name)%> + <%= link_to "Make a new Environmental Information request", new_request_to_body_url(:url_name => @public_body.url_name)%> to <%= h(@public_body.name) %> + <% else %> - <%= link_to make + " a new Freedom of Information request", new_request_to_body_url(:url_name => @public_body.url_name)%> + <%= _('<a href="%s">Make a new Freedom of Information request</a> to {{public_body_name}}', + :public_body_name => h(@public_body.name)) % new_request_to_body_url(:url_name => @public_body.url_name)%> <% end %> - to <%= h(@public_body.name) %> <% elsif @public_body.has_notes? %> <%= @public_body.notes_as_html %> <% elsif @public_body.not_requestable_reason == 'not_apply' %> - Freedom of Information law does not apply to this authority, so you cannot make - a request to it. + <%= _('Freedom of Information law does not apply to this authority, so you cannot make + a request to it.')%> <% elsif @public_body.not_requestable_reason == 'defunct' %> - This authority no longer exists, so you cannot make a request to it. + <%= _('This authority no longer exists, so you cannot make a request to it.')%> <% else %> - For an unknown reason, it is not possible to make a request to this authority. + <%= _('For an unknown reason, it is not possible to make a request to this authority.')%> <% end %> </strong> </div> <% if !@xapian_requests.nil? %> - <% if @xapian_requests.results.empty? %> + <% if @xapian_requests.results.empty? %> <% if @public_body.eir_only? %> <h2>Environmental Information Regulations requests made using this site</h2> + <h4>XXX this section needs localising re EIR as these are specific to UK law</h4> <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p> <% else %> - <h2>Freedom of Information requests made using this site</h2> - <p>Nobody has made any Freedom of Information requests to <%=h(@public_body.name)%> using this site yet.</p> + <h2> <%= _('Freedom of Information requests made using this site')%></h2> + <p> <%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p> <% end %> <% else %> <h2> <% if @public_body.eir_only? %> <%=pluralize(@public_body.info_requests.size, "Environmental Information Regulations request") %> made using this site <% else %> - <%=pluralize(@public_body.info_requests.size, "Freedom of Information request") %> made using this site + <%= n_('%d Freedom of Information request', '%d Freedom of Information requests', @public_body.info_requests.size) % @public_body.info_requests.size %> made using this site <% end %> <%= @page_desc %> </h2> @@ -91,15 +89,15 @@ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @public_body.info_requests.size) %> - <p>Only requests made using WhatDoTheyKnow.com are shown.</p> + <p> <%= _('Only requests made using {{site_name}} are shown.', :site_name => site_name) %></p> <% end %> <% else %> <% if @public_body.eir_only? %> <h2>Environmental Information Regulations requests made</h2> <% else %> - <h2>Freedom of Information requests made</h2> + <h2> <%= _('Freedom of Information requests made')%></h2> <% end %> - <p>The search index is currently offline, so we can't show the Freedom of Information requests that have been made to this authority.</p> + <p> <%= _('The search index is currently offline, so we can\'t show the Freedom of Information requests that have been made to this authority.')%></p> <% end %> diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml index 222bd938d..90e5f4605 100644 --- a/app/views/request/list.rhtml +++ b/app/views/request/list.rhtml @@ -1,12 +1,12 @@ <div id="list_sidebar"> <h1>Show only...</h1> <ul> -<% for view, description in [ - ['successful', "Successful responses"], - ['recent', "Recently sent requests"] +<% for view, description, target in [ + ['successful', "Successful responses", request_list_successful_url(:view => 'successful')], + ['recent', "Recently sent requests", request_list_recent_url(:view => 'recent')] ] %> -<li> - <%= link_to_unless (@view == view), description, request_list_url(:view => view) %> +<li> + <%= link_to_unless (@view == view), description, target %> </li> <% end %> </ul> |