Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sven Fuchs
committed
Oct 31, 2010
1 parent
03f0572
commit a08f6f3
Showing
13 changed files
with
70 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
class I18n::Message | ||
VERSION = "0.0.1" | ||
end | ||
module I18n | ||
class Message | ||
VERSION = "0.0.1" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
module Api | ||
module Cascade | ||
test "returns translation from attribute scope" do | ||
store_translations(:'models.model.attributes.attribute.message' => 'message') | ||
test "validation messages: returns translation from attribute scope" do | ||
cascade_options :step => 2, :skip_root => false, :scopes => [:model, :attribute] | ||
store_translations(:models => { :model => { :attributes => { :attribute => { :message => 'message' } } } }) | ||
assert_equal 'message', message(:message, :model => 'model', :attribute => 'attribute').to_s | ||
end | ||
|
||
test "returns translation from model scope" do | ||
store_translations(:'models.model.message' => 'message') | ||
test "validation messages: returns translation from model scope" do | ||
cascade_options :step => 2, :skip_root => false, :scopes => [:model, :attribute] | ||
store_translations(:models => { :model => { :message => 'message' } }) | ||
assert_equal 'message', message(:message, :model => 'model', :attribute => 'attribute').to_s | ||
end | ||
|
||
test "returns translation from errors scope" do | ||
test "validation messages: returns translation from errors scope" do | ||
cascade_options :step => 2, :skip_root => false, :scopes => [:model, :attribute] | ||
store_translations(:message => 'message') | ||
assert_equal 'message', message(:message, :model => 'model', :attribute => 'attribute').to_s | ||
end | ||
|
||
test 'view helper: returns the :edit translation from the view path scope admin.sites.menu' do | ||
cascade_options :step => 1, :skip_root => false, :offset => 2 | ||
store_translations(:admin => { :sites => { :menu => { :edit => 'edit' } } }) | ||
assert_equal 'edit', message(:edit, :scope => 'admin.sites.menu').to_s | ||
end | ||
|
||
test 'view helper: returns the :edit translation from the view path scope admin.menu' do | ||
cascade_options :step => 1, :skip_root => false, :offset => 2 | ||
store_translations(:admin => { :menu => { :edit => 'edit' } }) | ||
assert_equal 'edit', message(:edit, :scope => 'admin.sites.menu').to_s | ||
end | ||
|
||
test 'view helper: returns the :edit translation from the view path scope menu' do | ||
cascade_options :step => 1, :skip_root => false, :offset => 2 | ||
store_translations(:menu => { :edit => 'edit' }) | ||
assert_equal 'edit', message(:edit, :scope => 'admin.sites.menu').to_s | ||
end | ||
|
||
# currently not supported by I18n::Cascade because of the way :offset is used | ||
# | ||
# test 'view helper: returns the :edit translation from the root scope' do | ||
# cascade_options :step => 1, :skip_root => false, :offset => 2 | ||
# store_translations(:edit => 'edit') | ||
# assert_equal 'edit', message(:edit, :scope => 'admin.sites.menu').to_s | ||
# end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# encoding: utf-8 | ||
|
||
dir = File.dirname(__FILE__) | ||
$LOAD_PATH.unshift(dir) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters