Sha256: 2bfa148a6a8d058776c075f77390b04706819cc79521a42b0c5e36192057dae4

Contents?: true

Size: 503 Bytes

Versions: 16

Compression:

Stored size: 503 Bytes

Contents

module I18n::Tasks::RelativeKeys

  # @param key [String] relative i18n key (starts with a .)
  # @param path [String] path to the file containing the key
  # @return [String] absolute version of the key
  def absolutize_key(key, path)
    # normalized path
    path   = Pathname.new(File.expand_path path).relative_path_from(Pathname.new(Dir.pwd)).to_s
    # key prefix based on path
    prefix = path.gsub(%r(app/views/|(\.[^/]+)*$), '').tr('/', '.').gsub(%r(\._), '.')
    "#{prefix}#{key}"
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
i18n-tasks-0.2.12 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.11 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.10 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.9 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.8 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.7 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.6 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.5 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.4 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.3 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.2 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.1 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.2.0 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.1.8 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.1.7 lib/i18n/tasks/relative_keys.rb
i18n-tasks-0.1.6 lib/i18n/tasks/relative_keys.rb