Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internationalization 从使用haml标记的简单表单中调用I18n翻译方法_Internationalization_Haml_Translation_Simple Form_I18n Gem - Fatal编程技术网

Internationalization 从使用haml标记的简单表单中调用I18n翻译方法

Internationalization 从使用haml标记的简单表单中调用I18n翻译方法,internationalization,haml,translation,simple-form,i18n-gem,Internationalization,Haml,Translation,Simple Form,I18n Gem,我正在使用i18ngem,我只是想知道在使用基于haml的simple_表单时如何调用翻译方法。目前我的代码如下: <% title t('new_tenant.title') %> <h2><%= t 'new_tenant.header' %></h2> \users\new.html.haml -内容:标题“管理员|创建新用户” .页眉 %h1创建新用户 /config/localses/en.yml 嗯: 新租户: 标题:“租户管理|创建

我正在使用i18ngem,我只是想知道在使用基于haml的simple_表单时如何调用翻译方法。目前我的代码如下:

<% title t('new_tenant.title') %>
<h2><%= t 'new_tenant.header' %></h2>
\users\new.html.haml -内容:标题“管理员|创建新用户” .页眉 %h1创建新用户

/config/localses/en.yml 嗯: 新租户: 标题:“租户管理|创建新租户” 标题:“创建新租户”

/config/localses/de.yml 判定元件: 新租户: 标题:“Mieter管理|创建新Mieter” 标题:“厄斯泰伦·纽尔·迈特”

我在Railcasts第138集中看到,这可以被称为:

<% title t('new_tenant.title') %>
<h2><%= t 'new_tenant.header' %></h2>

如何将相同的方法应用于haml标记?任何提示都将不胜感激。

给你

%title=t 'new_tenant.title' 
%h2=t 'new_tenant.header'
有时您不能使用i18n速记t,在这种情况下,只需使用i18n.t而不是快捷方式。祝你好运