0
我有一個Highcharts圖,裏面有文本。如何根據所選語言更改此文本?這裏是我的代碼:Ruby on Rails i18n更改Ajax內部的文本
var chart;
chart = new Highcharts.Chart({
(...)
subtitle: {
text: document.ontouchstart === undefined ?
'Click and drag in the plot area to zoom in' :
'Drag your finger over the plot to zoom in'
}
(...)
我en.yml文件看起來像:
en:
actions:
zoom: "Click and drag in the plot area to zoom in"
我已經試過
t("actions.zoom")
和
<% t "actions.zoom" %>
但他們沒有工作在Ajax裏面。我應該怎麼做 ?
我的文件名爲index.html.erb。我試過index.html.js.erb,但後來出現「模板丟失」錯誤 – 2013-03-19 21:41:45
您的javascript不在外部js文件中?那麼我假設你已經使用'
嘗試使用i18n-js寶石通過Rails
I18n.locale
到您的JavaScript文件。來源
2013-03-20 12:57:30