Module: I18n::Processes::Scanners::RelativeKeys
- Included in:
- PatternMapper, PatternScanner, RubyAstScanner
- Defined in:
- lib/i18n/processes/scanners/relative_keys.rb
Instance Method Summary collapse
-
#absolute_key(key, path, roots: config[:relative_roots], calling_method: nil) ⇒ String
Absolute version of the key.
Instance Method Details
#absolute_key(key, path, roots: config[:relative_roots], calling_method: nil) ⇒ String
Returns absolute version of the key.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/i18n/processes/scanners/relative_keys.rb', line 11 def absolute_key(key, path, roots: config[:relative_roots], calling_method: nil) return key unless key.start_with?(DOT) fail 'roots argument is required' unless roots.present? normalized_path = File.(path) (root = path_root(normalized_path, roots)) || fail(CommandError, "Cannot resolve relative key \"#{key}\".\n" \ "Set search.relative_roots in config/i18n-processes.yml (currently #{roots.inspect})") normalized_path.sub!(root, '') "#{prefix(normalized_path, calling_method: calling_method)}#{key}" end |