Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
35bad508
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35bad508
编写于
7月 04, 2008
作者:
S
Sven Fuchs
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'i18n' of git@github.com:svenfuchs/rails into i18n
上级
e1a7f83f
d41e4c1c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
16 deletion
+14
-16
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+2
-2
actionmailer/test/i18n_test.rb
actionmailer/test/i18n_test.rb
+12
-14
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
35bad508
...
...
@@ -346,10 +346,10 @@ class Base
# Specify the charset to use for the message.
# It performs a lookup, on the specified charset, then on the charset from
# the current locale, and,
finally
, on the +default_charset+ specified
# the current locale, and,
in the end
, on the +default_charset+ specified
# for ActionMailer::Base.
def
charset
(
charset
=
nil
)
@charset
||=
charset
||
I18n
.
translate
(
:charset
)
||
@@default_charset
@charset
||=
charset
||
I18n
.
translate
(
:charset
,
:default
=>
@@default_charset
)
end
attr_writer
:charset
...
...
actionmailer/test/i18n_test.rb
浏览文件 @
35bad508
...
...
@@ -59,37 +59,35 @@ def test_should_use_locale_charset
end
def
test_should_use_default_charset_if_no_current_locale
uses
_locale
nil
do
with
_locale
nil
do
assert_equal
@charset
,
mail
.
charset
end
end
def
test_mail_headers_should_contains_current_charset
uses
_locale
'de-DE'
do
with
_locale
'de-DE'
do
assert_match
/iso-8859-1/
,
mail
.
header
[
'content-type'
].
body
end
end
def
test_should_use_charset_from_current_locale
uses
_locale
'de-DE'
do
with
_locale
'de-DE'
do
assert_equal
'iso-8859-1'
,
mail
.
charset
end
end
def
test_should_raise_exception_if_current_locale_doesnt_specify_a_charset
assert_raise
I18n
::
MissingTranslationData
do
uses_locale
'en-GB'
do
mail
end
def
test_should_use_default_charset_if_missing_for_current_locale
with_locale
'en-GB'
do
assert_equal
@charset
,
mail
.
charset
end
end
def
test_should_use_explicit_charset
assert_equal
'iso-8859-2'
,
mail
(
'use_explicit_charset'
).
charset
end
def
test_mail_parts_charsets
uses
_locale
'de-DE'
do
with
_locale
'de-DE'
do
charsets
=
mail
(
'multiparted'
).
parts
.
map
(
&
:charset
)
assert_equal
'iso-8859-1'
,
charsets
[
0
]
assert_equal
'iso-8859-1'
,
charsets
[
1
]
...
...
@@ -98,7 +96,7 @@ def test_mail_parts_charsets
end
def
test_mail_parts_headers
uses
_locale
'de-DE'
do
with
_locale
'de-DE'
do
content_types
=
mail
(
'multiparted'
).
parts
.
map
(
&
:header
).
map
do
|
header
|
header
[
'content-type'
].
body
end
...
...
@@ -111,7 +109,7 @@ def test_mail_parts_headers
# TODO: this case depends on XML Builder,
# should we pass Builder::XmlMarkup.new :encoding => charset_from_i18n ?
def
_ignore_test_rxml_template_should_use_current_charset
uses
_locale
'de-DE'
do
with
_locale
'de-DE'
do
assert_equal
"<?xml version=
\"
1.0
\"
encoding=
\"
iso-8859-1
\"
?>
\n
<test/>"
,
mail
(
'rxml_template'
).
body
.
strip
end
...
...
@@ -122,7 +120,7 @@ def mail(method = 'use_locale_charset')
I18nMailer
.
__send__
(
'create_'
+
method
,
@recipient
)
end
def
uses
_locale
(
locale
,
&
block
)
def
with
_locale
(
locale
,
&
block
)
begin
I18n
.
locale
=
locale
yield
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录