0

我正在完成我网站的不同本地化,我在设计电子邮件模板中遇到了一个小问题。

例如,在确认电子邮件中,我已将其全部翻译,但用于确认帐户的链接是使用此代码段自动生成的:

<%= link_to t('devise.mailer.confirmation_instructions.confirm_link'), confirmation_url(@resource, :confirmation_token => @token) %>

这个自动生成的链接始终指向我的 .com Web 版本,我希望它是有条件的,具体取决于域 (.com/.es)。当链接不是自动生成时,我可以使用:

if request.host.split('.').last == "com"

或者

if request.host.split('.').last == "es"

但在这种情况下,我不知道我该怎么做。

有什么建议吗?

谢谢。

4

1 回答 1

1

您可以将:host 参数添加到您的confirmation_url(@resource, :confirmation_token => @token),并在翻译表中查找正确的主机:

confirmation_url(@resource, :confirmation_token => @token, host: t('host'))

在您的 yaml 文件中,您“翻译”用户语言的正确主机,例如

en:
  host: 'www.example.com'
于 2014-01-12T13:20:13.407 回答