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, Check::SEVERITY_VALUES
Instance Attribute Summary
Attributes inherited from Check
#ignored_patterns, #offenses, #options, #theme
Instance Method Summary collapse
Methods included from ChecksTracking
Methods included from ParsingHelpers
Methods inherited from Check
#==, #add_offense, all, can_disable, #can_disable?, categories, #categories, category, #code_name, doc, #doc, docs_url, #ignore!, #ignored?, #severity, severity, #severity=, #severity_value, severity_value, single_file, #single_file?, #to_s, #whole_theme?
Methods included from JsonHelpers
Instance Method Details
#on_variable(node) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/theme_check/checks/translation_key_exists.rb', line 20 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) || SystemTranslations.include?(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 |