Sha256: 799c2cc518111afa41387209e29cb26a46e56217e424c5d7116b39a649c7e26a
Contents?: true
Size: 756 Bytes
Versions: 3
Compression:
Stored size: 756 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, roots = relative_roots) # normalized path path = File.expand_path path (path_root = roots.map { |path| File.expand_path path }.sort.reverse.detect { |root| path.start_with?(root + '/') }) or raise "No relative key root detected for \"#{key}\" at #{path}. Please set relative_roots in config/i18n-tasks.yml (currently set to #{relative_roots})" # key prefix based on path prefix = path.gsub(%r(#{path_root}/|(\.[^/]+)*$), '').tr('/', '.').gsub(%r(\._), '.') "#{prefix}#{key}" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
i18n-tasks-0.2.15 | lib/i18n/tasks/relative_keys.rb |
i18n-tasks-0.2.14 | lib/i18n/tasks/relative_keys.rb |
i18n-tasks-0.2.13 | lib/i18n/tasks/relative_keys.rb |