# frozen_string_literal: true

require "rails_translation_manager/version"
require "rails_translation_manager/railtie" if defined?(Rails)
require "rails-i18n"

require "rails_translation_manager/locale_checker/base_checker"
require "rails_translation_manager/locale_checker/locale_checker_helper"
require "rails_translation_manager/locale_checker/missing_foreign_locales"
require "rails_translation_manager/locale_checker/missing_english_locales"

module RailsTranslationManager
  autoload :Exporter, "rails_translation_manager/exporter"
  autoload :Importer, "rails_translation_manager/importer"
  autoload :Stealer, "rails_translation_manager/stealer"
end

# frozen_string_literal: true

require "rails_translation_manager/version"
require "rails_translation_manager/railtie" if defined?(Rails)
require "rails-i18n"

require "rails_translation_manager/locale_checker/base_checker"
require "rails_translation_manager/locale_checker/locale_checker_helper"
require "rails_translation_manager/locale_checker/missing_foreign_locales"
require "rails_translation_manager/locale_checker/missing_english_locales"

module RailsTranslationManager
  autoload :Exporter, "rails_translation_manager/exporter"
  autoload :Importer, "rails_translation_manager/importer"
  autoload :Stealer, "rails_translation_manager/stealer"

  rails_i18n_path = Gem::Specification.find_by_name("rails-i18n").gem_dir
  rails_translation_manager = Gem::Specification.find_by_name("rails_translation_manager").gem_dir

  I18n.load_path.concat(
    Dir["#{rails_i18n_path}/rails/pluralization/*.rb"],
    ["#{rails_translation_manager}/config/locales/plurals.rb"]
  )
end

Add plural rules to I18n load path
Add plural rules to I18n load path

This adds the native plural rules in rails-i18n and the bespoke list we
created in `config/locales/plurals.rb`. This allows them to be located
when we lookup the plural rules for all our supported languages.

`concat` and `Dir` have been used instead of `<< `..pluralization/*.rb`
for adding files to the load path due to the tests being unable to
expand the path, generating the below error:

```
 Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/peterhartshorn/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rails-i18n-6.0.0/rails/pluralization/*.rb
```
