Class: RailsAiContext::Introspectors::I18nIntrospector

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_context/introspectors/i18n_introspector.rb

Overview

Discovers internationalization setup: locales, backends, key counts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ I18nIntrospector

Returns a new instance of I18nIntrospector.



11
12
13
# File 'lib/rails_ai_context/introspectors/i18n_introspector.rb', line 11

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



9
10
11
# File 'lib/rails_ai_context/introspectors/i18n_introspector.rb', line 9

def app
  @app
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails_ai_context/introspectors/i18n_introspector.rb', line 15

def call
  result = {
    default_locale: I18n.default_locale.to_s,
    available_locales: I18n.available_locales.map(&:to_s).sort,
    backend: I18n.backend.class.name,
    locale_files: extract_locale_files,
    total_locale_files: count_locale_files,
    locale_coverage: detect_locale_coverage
  }
  result.merge!(detect_fallback_config)
  result
rescue => e
  { error: e.message }
end