Class: ThemeCheck::TranslationKeyExists
- Inherits:
-
LiquidCheck
- Object
- Check
- LiquidCheck
- ThemeCheck::TranslationKeyExists
- Defined in:
- lib/theme_check/checks/translation_key_exists.rb
Constant Summary
Constants inherited from Check
Check::CATEGORIES, Check::SEVERITIES
Instance Attribute Summary
Attributes inherited from Check
Instance Method Summary collapse
Methods inherited from LiquidCheck
Methods included from ChecksTracking
Methods included from ParsingHelpers
Methods inherited from Check
all, can_disable, #can_disable?, category, #category, #code_name, doc, #doc, #ignore!, #ignored?, #severity, severity, #to_s, #unignore!
Methods included from JsonHelpers
Instance Method Details
#on_variable(node) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/theme_check/checks/translation_key_exists.rb', line 7 def on_variable(node) return unless @theme.default_locale_json&.content&.is_a?(Hash) return unless node.value.filters.any? { |name, _| name == "t" || name == "translate" } return unless (key_node = node.children.first) return unless key_node.value.is_a?(String) unless key_exists?(key_node.value) add_offense( "'#{key_node.value}' does not have a matching entry in '#{@theme.default_locale_json.relative_path}'", node: node, markup: key_node.value, ) end end |