forked from spree/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
missing_translations.rb
24 lines (23 loc) · 884 Bytes
/
missing_translations.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'yaml'
require 'pry'
hash = YAML.load_file("core/config/locales/en.yml")
hash["en"]["spree"].each do |k,v|
if String === v
# Check for translations used in controllers, models, views, mailers, helpers and lib
command = %Q{ack "t\\(:#{k}" */app/**/* */lib/**}
# Check for possible preferences matching translations
# This is because preference_field within backend uses it like Spree.t(:<preference_key>)
symbol_command = %Q{ack ":#{k}" */app/**/* */lib/**}
`#{command}`
command_status = $?.exitstatus
`#{symbol_command}`
symbol_command_status = $?.exitstatus
if command_status == 1 && symbol_command_status == 1
puts "Couldn't find #{k} translation"
end
else
# TODO: Account for nested keys.
# I didn't do this because there's not that many nested keys in en.yml
# and it's easy to verify with my eyes.
end
end