class Granite::Translations
Public Class Methods
combine_paths(paths1, paths2)
click to toggle source
# File lib/granite/translations.rb, line 4 def combine_paths(paths1, paths2) paths1.flat_map do |path1| paths2.map { |path2| [*path1, *path2].join('.') } end end
scope_translation_args(scopes, key, *, **options)
click to toggle source
# File lib/granite/translations.rb, line 10 def scope_translation_args(scopes, key, *, **options) lookups = expand_relative_key(scopes, key) + Array(options[:default]) key = lookups.shift options[:default] = lookups [key, options] end
Private Class Methods
expand_relative_key(scopes, key)
click to toggle source
# File lib/granite/translations.rb, line 21 def expand_relative_key(scopes, key) return [key] unless key.is_a?(String) && key.start_with?('.') combine_paths(scopes, [key.sub(/^\./, '')]).map(&:to_sym) end