Sha256: 1eedf1edc82f82251cbf74728bb7863b9e4d11ea5c93874d8cbc41fea0360de5
Contents?: true
Size: 571 Bytes
Versions: 4
Compression:
Stored size: 571 Bytes
Contents
# frozen_string_literal: true module Bridgetown module Filters module TranslationFilters def t(input, options = "") options = string_to_hash(options) locale = options.delete(:locale) count = options.delete(:count) options[:count] = count.to_i unless count.nil? I18n.t(input.to_s, locale: locale, **options) rescue ArgumentError input end private def string_to_hash(options) options.split(",").to_h { |e| e.split(":").map(&:strip) }.symbolize_keys end end end end
Version data entries
4 entries across 4 versions & 1 rubygems