Ruby on rails 3 为什么I18n.locale不是字符串

Ruby on rails 3 为什么I18n.locale不是字符串,ruby-on-rails-3,internationalization,Ruby On Rails 3,Internationalization,我正在访问I18n.locale变量以确定语言,我必须将其转换为字符串以随时进行比较 I18n.locale.to_s 如 I18n.locale.to_s == "en" ? "h2-high-quality.gif" : "h2-high-quality-fr.gif" 我做错了什么,还是必须这样做?I18n.语言环境是一个符号。您不需要转换为字符串来进行比较,只需对符号进行比较即可: I18n.locale == :en ? "h2-high-quality.gif" : "h2-hi

我正在访问I18n.locale变量以确定语言,我必须将其转换为字符串以随时进行比较

I18n.locale.to_s

I18n.locale.to_s == "en" ? "h2-high-quality.gif" : "h2-high-quality-fr.gif"

我做错了什么,还是必须这样做?

I18n.语言环境是一个符号。您不需要转换为字符串来进行比较,只需对符号进行比较即可:

I18n.locale == :en ? "h2-high-quality.gif" : "h2-high-quality-fr.gif"

I18n.locale
是一个符号。您不需要转换为字符串来进行比较,只需对符号进行比较即可:

I18n.locale == :en ? "h2-high-quality.gif" : "h2-high-quality-fr.gif"