mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Add sketch of I18n error translation
This commit is contained in:
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
---
|
||||
simple: "less is more"
|
||||
whatever: "something :something"
|
||||
errors:
|
||||
i18n:
|
||||
undefined_interpolation: "undefined key :key"
|
||||
unknown_translation: "translation ':name' wasn't found"
|
||||
syntax:
|
||||
oops: "something wasn't right"
|
||||
@@ -0,0 +1,33 @@
|
||||
require 'test_helper'
|
||||
|
||||
class I18nTest < Test::Unit::TestCase
|
||||
include Liquid
|
||||
|
||||
def setup
|
||||
@i18n = I18n.new("./test/fixtures/en_locale.yml")
|
||||
end
|
||||
|
||||
def test_simple_translate_string
|
||||
assert_equal "less is more", @i18n.translate("simple")
|
||||
end
|
||||
|
||||
def test_nested_translate_string
|
||||
assert_equal "something wasn't right", @i18n.translate("errors.syntax.oops")
|
||||
end
|
||||
|
||||
def test_single_string_interpolation
|
||||
assert_equal "something different", @i18n.translate("whatever", :something => "different")
|
||||
end
|
||||
|
||||
def test_raises_keyerror_on_undefined_interpolation_key
|
||||
assert_raise I18n::TranslationError do
|
||||
@i18n.translate("whatever", :oopstypos => "yes")
|
||||
end
|
||||
end
|
||||
|
||||
def test_raises_unknown_translation
|
||||
assert_raise I18n::TranslationError do
|
||||
@i18n.translate("doesnt_exist")
|
||||
end
|
||||
end
|
||||
end
|
||||
+3
-1
@@ -7,7 +7,9 @@ begin
|
||||
rescue LoadError
|
||||
puts "Couldn't load ruby-debug. gem install ruby-debug if you need it."
|
||||
end
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'liquid')
|
||||
|
||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
||||
require 'liquid.rb'
|
||||
|
||||
mode = :strict
|
||||
if env_mode = ENV['LIQUID_PARSER_MODE']
|
||||
|
||||
Reference in New Issue
Block a user