diff --git a/CHANGELOG.md b/CHANGELOG.md index 804c36a39..af7c43690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changes since last non-beta release. - Fixed `react_component_hash` functionality in cases of prerendering errors: [PR 960](https://github.com/shakacode/react_on_rails/pull/960) by [Judahmeek](https://github.com/Judahmeek) *Please add entries here for your pull requests.* +- Fixes check for i18n_dir in LocalesToJs returning false when i18n_dir was set. [PR 899](https://github.com/shakacode/react_on_rails/pull/899) by [hakongit](https://github.com/hakongit) ### [10.0.0] - 2017-10-08 #### Created diff --git a/lib/react_on_rails/locales_to_js.rb b/lib/react_on_rails/locales_to_js.rb index d2da631ca..56d1faed3 100644 --- a/lib/react_on_rails/locales_to_js.rb +++ b/lib/react_on_rails/locales_to_js.rb @@ -5,7 +5,10 @@ module ReactOnRails class LocalesToJs def initialize - return if i18n_dir.blank? + if !i18n_dir.nil? && !File.directory?(i18n_dir) + raise "config.i18n_dir is set and it is not a directory. Did you set config.i18n_dir in the react_on_rails initializer?" + end + return if i18n_yml_dir.nil? return unless obsolete? @translations, @defaults = generate_translations convert diff --git a/spec/react_on_rails/locales_to_js_spec.rb b/spec/react_on_rails/locales_to_js_spec.rb index 159caad57..af650bfa4 100644 --- a/spec/react_on_rails/locales_to_js_spec.rb +++ b/spec/react_on_rails/locales_to_js_spec.rb @@ -9,6 +9,13 @@ module ReactOnRails let(:translations_path) { "#{i18n_dir}/translations.js" } let(:default_path) { "#{i18n_dir}/default.js" } + it "with i18n_dir set to ''" do + ReactOnRails.configure do |config| + config.i18n_dir = '' + end + expect { ReactOnRails::LocalesToJs.new }.to raise_error(/config.i18n_dir is set and it is not a directory. Did you set config.i18n_dir in the react_on_rails initializer?/) + end + shared_examples "locale to js" do context "with obsolete js files" do before do