0

I tried using the asset pipeline instructions for the i18n-js gem but that didn't work.

A previous developer used the gem and generated the translations.js file somehow but then completely removed the i18n-js gem and configuration options except removing the translations.js file. So now I have the translations.js file in the repo at this file path public/javascripts/translations.js with the following configuration options that I set up. However,

When I run

rake i18n:js:export

it runs, but nothing happens. Please help me get my translations.js file to update

config/i18n-js.yml

translations:
- file: "app/assets/javascripts/application/i18n/translations.js"
  only: '*.js*'

config/initializers/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

app/views/layouts/_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

Inside en.yml

  js:
    posts:
      select2:
        placeholder: 'Please, select tags'
        no-matches: 'No tags found'
Pavan Katepalli
  • 2,372
  • 4
  • 29
  • 52

1 Answers1

0

The issue was that the following directory doesn't exist: app/assets/javascripts/application/i18n

- file: "app/assets/javascripts/application/i18n/translations.js"
Pavan Katepalli
  • 2,372
  • 4
  • 29
  • 52