Method: Satis::ApplicationComponent#ct

Defined in:
app/components/satis/application_component.rb

#ct(key = nil, **options) ⇒ Object

This provides us with a translation helper which scopes into the original view and thereby conveniently scopes the translations.

In your component.html.slim you can use: “‘slim

ct(“.#Satis::ApplicationComponent.tabtab.name”, scope: [group.to_sym])

““

It’ll then try and find a translation with scope: en.admin.spaces.edit.tabs.main.admin_versions



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/components/satis/application_component.rb', line 21

def ct(key = nil, **options)
  scope = Array.wrap(options.delete(:scope))

  scope = if scope
            scope.unshift(i18n_scope)
          else
            [i18n_scope]
          end

  scope = original_i18n_scope.concat(scope)

  key = key&.to_s unless key.is_a?(String)
  key = "#{scope.join('.')}#{key}" if key.start_with?('.')

  original_view_context.t(key, **options)
end