我尝试使用i18n-js gem的资产管道说明但是没有用。
以前的开发人员使用gem并以某种方式生成了translations.js文件,但之后完全删除了i18n-js gem和配置选项,除了删除translations.js文件。所以现在我在这个文件路径为public / javascripts / translations.js的repo中有translations.js文件,其中包含我设置的以下配置选项。然而,
当我跑步时
rake i18n:js:export
它运行,但没有任何反应。请帮我翻译我的translations.js文件
配置/ I18N-js.yml
translations:
- file: "app/assets/javascripts/application/i18n/translations.js"
only: '*.js*'
配置/初始化/ assets.rb
Rails.application.config.assets.precompile += %w( forem.css forem.js i18n.js )
的Gemfile
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.4'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails', '~> 3.1.1'
gem 'turbolinks', '~> 2.2.2'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'sass-rails', '~> 4.0.3'
gem 'bootstrap-sass', '~> 3.2.0.0'
gem 'autoprefixer-rails'
gem 'devise', '~> 3.2.4'
gem 'cancancan', '~> 1.9.2'
gem 'pg', '~> 0.17.1'
gem "select2-rails", '~> 3.5.7'
gem 'language_list', '~> 1.0.0'
gem 'country_select', github: 'stefanpenner/country_select'
gem "friendly_id", "~> 5.0.4"
gem 'i18n', '~> 0.6.11' # had to include this to get friendly_id generator to work - also works in conjunction with the globalize gem and globalize-accessors gem
gem 'globalize', '~> 4.0.2' # let's you use multiple locales for one model without making a ton of columns
gem 'globalize-accessors', '~> 0.1.5' #Easily access (read and write) globalize translated fields without fiddling with locale
gem 'batch_translations' #needed this to get globalize_fields_for to work
gem "i18n-js", ">= 3.0.0.rc8" #get internationalization to work with javascript in rails
gem 'momentjs-rails', '>= 2.8.1'
gem 'bootstrap3-datetimepicker-rails', '~> 3.1.2'
gem 'fog', github: 'fog/fog'
gem 'carrierwave'
gem "figaro" #application.yml handling
gem 'bootstrap-wysihtml5-rails', :github => "bleakwood/bootstrap-wysihtml5-rails"
gem 'negative_captcha'
# these two have to be together
#gem 'forem', :github => "radar/forem", :branch => "rails4"
gem 'forem', :git => 'git://github.com/radar/forem.git', :ref => '8b4999af3c702603414f6ba9efc1848a0cdb6dbe'
gem 'kaminari', '~> 0.16.1'
gem 'forem-redcarpet', '~> 1.0.2'
# these two have to go together
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary', :github => "zakird/wkhtmltopdf_binary_gem"
gem 'highcharts-rails', '~> 4.0.1'
# audit trail
gem "audited-activerecord", "~> 4.0" #https://github.com/collectiveidea/audited
# making a curl call
gem 'httparty', '~> 0.13.1'
# try this without the gem
# put this into application.js
# //= require sweet-alert-confirm
#gem 'sweet-alert-confirm', '~> 0.0.3'
# our js framework of choice
gem 'knockoutjs-rails', '~> 3.2.0'
gem 'whenever', '~> 0.9.4'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_21]
gem 'quiet_assets'
gem 'rails_layout'
gem 'meta_request'
gem 'pry', '~> 0.10.1'
end
group :development, :test do
gem 'factory_girl_rails'
gem 'rspec-rails'
end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'faker'
gem 'launchy'
gem 'selenium-webdriver'
end
应用程序/视图/布局/ _js_locales_info.html.erb
<%= javascript_include_tag "i18n" %>
<%= javascript_include_tag "translations" %>
<%= javascript_tag do %>
I18n.defaultLocale = "<%= I18n.default_locale %>";
I18n.locale = "<%= I18n.locale %>";
I18n.fallbacks = true;
<% end %>
application.html.erb
<!-- after all the other js stuff-->
<%= render 'layouts/js_locales_info' %>
application.rb中
#for the i18n-js gem
config.middleware.use I18n::JS::Middleware
内部en.yml
js:
posts:
select2:
placeholder: 'Please, select tags'
no-matches: 'No tags found'
答案 0 :(得分:0)
问题是以下目录不存在:app / assets / javascripts / application / i18n
- file: "app/assets/javascripts/application/i18n/translations.js"