Commit eeb9010e by Greg Price

Respect Accept-Language when getting strings

parent 636395fb
......@@ -56,3 +56,4 @@ gem 'newrelic_moped'
gem 'unicorn'
gem "rack-timeout", "0.1.0beta3"
gem "i18n"
gem "rack-contrib", :git => 'https://github.com/rack/rack-contrib.git', :ref => '6ff3ca2b2d988911ca52a2712f6a7da5e064aa27'
......@@ -35,6 +35,14 @@ GIT
specs:
voteable_mongo (0.9.3)
GIT
remote: https://github.com/rack/rack-contrib.git
revision: 6ff3ca2b2d988911ca52a2712f6a7da5e064aa27
ref: 6ff3ca2b2d988911ca52a2712f6a7da5e064aa27
specs:
rack-contrib (1.2.0)
rack (>= 0.9.1)
GEM
remote: https://rubygems.org/
specs:
......@@ -185,6 +193,7 @@ DEPENDENCIES
nokogiri
pry
pry-nav
rack-contrib!
rack-test
rack-timeout (= 0.1.0beta3)
rake
......
......@@ -63,6 +63,7 @@ Moped.logger.level = ENV["ENABLE_MOPED_DEBUGGING"] ? Logger::DEBUG : Logger::INF
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locale', '*.yml').to_s]
I18n.default_locale = CommentService.config[:default_locale]
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
use Rack::Locale
helpers do
def t(*args)
......
x-test:
requested_object_not_found: "##x-test## requested object not found"
user_id_is_required: "##x-test## User id is required"
source_type_must_be_user_thread_or_other: "##x-test## Source type must be 'user', 'thread' or 'other'"
value_is_required: "##x-test## Value is required"
value_is_invalid: "##x-test## Value is invalid"
anonymous: "##x-test## anonymous"
blocked_content_with_body_hash: "##x-test## blocked content with body hash %{hash}"
param_must_be_a_non_negative_number: "##x-test## %{param} must be a non-negative number"
param_must_be_a_number_greater_than_zero: "##x-test## %{param} must be a number greater than zero"
require "spec_helper"
describe "i18n" do
it "should respect the Accept-Language header" do
put "/api/v1/comments/does_not_exist/votes", {}, {"HTTP_ACCEPT_LANGUAGE" => "x-test"}
last_response.status.should == 400
parse(last_response.body).first.should == "##x-test## requested object not found"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment