From 0196035acd1d7d113a7130263fda23f096306c84 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 18 Jan 2013 13:22:28 +1100 Subject: Override n_ to add interpolation --- lib/i18n_fixes.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/i18n_fixes.rb b/lib/i18n_fixes.rb index a85faddcb..82d1b2c3a 100644 --- a/lib/i18n_fixes.rb +++ b/lib/i18n_fixes.rb @@ -14,6 +14,17 @@ def _(key, options = {}) gettext_interpolate(translation, options) end +def n_(*keys) + # The last parameter should be the values to do the interpolation with + if keys.count > 3 + options = keys.pop + else + options = {} + end + translation = FastGettext.n_(*keys).html_safe + gettext_interpolate(translation, options) +end + MATCH = /\{\{([^\}]+)\}\}/ def gettext_interpolate(string, values) -- cgit v1.2.3 From a47237d6843f14a2270e2c4e80fd1a41a661974a Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 17 Apr 2013 12:55:18 +0100 Subject: Also silence network unreachable errors. --- lib/quiet_opener.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb index bde645d0b..ae6605c43 100644 --- a/lib/quiet_opener.rb +++ b/lib/quiet_opener.rb @@ -3,7 +3,7 @@ require 'net-purge' require 'net/http/local' def quietly_try_to_open(url) - begin + begin result = open(url).read.strip rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET Rails.logger.warn("Unable to open third-party URL #{url}") @@ -11,12 +11,12 @@ def quietly_try_to_open(url) end return result end - + def quietly_try_to_purge(host, url) - begin + begin result = "" result_body = "" - Net::HTTP.bind '127.0.0.1' do + Net::HTTP.bind '127.0.0.1' do Net::HTTP.start(host) {|http| request = Net::HTTP::Purge.new(url) response = http.request(request) @@ -24,7 +24,7 @@ def quietly_try_to_purge(host, url) result_body = response.body } end - rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET + rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, Errno::ENETUNREACH Rails.logger.warn("PURGE: Unable to reach host #{host}") end if result == "200" @@ -34,4 +34,4 @@ def quietly_try_to_purge(host, url) end return result end - + -- cgit v1.2.3