Sha256: 5ca89025a2d317c59c143133ab25eea8fd88721ef8fca8a63e8b6247aeaeb3b5
Contents?: true
Size: 784 Bytes
Versions: 16
Compression:
Stored size: 784 Bytes
Contents
# frozen_string_literal: true module ThemeCheck module ShopifyLiquid module SystemTranslations extend self def translations @translations ||= YAML.load(File.read("#{__dir__}/../../../data/shopify_translation_keys.yml")).to_set end def translations_hash @translations_hash ||= translations.reduce({}) do |acc, k| dig_set(acc, k.split('.'), "") end end def include?(key) translations.include?(key) end private def dig_set(obj, keys, value) key = keys.first if keys.length == 1 obj[key] = value else obj[key] = {} unless obj[key] dig_set(obj[key], keys.slice(1..-1), value) end obj end end end end
Version data entries
16 entries across 16 versions & 1 rubygems