Class: TranslationsController
Instance Method Summary
collapse
#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token
Instance Method Details
#auth ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/translations_controller.rb', line 22
def auth
I18n.locale = translations_params[:locale]
translations = load_translations.slice(:auth, :general, :languages)
render json: {
translations: flatten_hash(translations),
locale: I18n.locale
}
end
|
#index ⇒ Object
4
5
6
7
8
9
10
|
# File 'app/controllers/translations_controller.rb', line 4
def index
translations = load_translations
render json: {
translations: flatten_hash(translations),
locale: I18n.locale
}
end
|
#onboard ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/translations_controller.rb', line 12
def onboard
I18n.locale = translations_params[:locale]
translations = load_translations.slice(:onboard, :auth, :form, :general, :languages)
render json: {
translations: flatten_hash(translations),
locale: I18n.locale
}
end
|
#show ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/translations_controller.rb', line 32
def show
keys = params[:keys]
translations = keys.each_with_object({}) do |key, hash|
if key.end_with?('.*')
base_key = key.chomp('.*')
nested_translations = retrieve_translation(base_key)
nested_translations.each do |nested_key, value|
hash["#{base_key}.#{nested_key}"] = value
end
else
hash[key] = retrieve_translation(key)
end
end
render json: {
translations: flatten_hash(translations),
locale: I18n.locale
}
end
|