Skip to content

Instantly share code, notes, and snippets.

@Bor1s
Last active September 12, 2018 08:44
Show Gist options
  • Select an option

  • Save Bor1s/d89af83c61349e14c1605465a9a7f46e to your computer and use it in GitHub Desktop.

Select an option

Save Bor1s/d89af83c61349e14c1605465a9a7f46e to your computer and use it in GitHub Desktop.
Script to show all nested I18n
def key_paths(key, hash_or_string)
if hash_or_string.is_a?(Hash)
hash_or_string.keys.map do |subkey|
key_paths([key, subkey].compact.join("."), hash_or_string[subkey])
end
else
key
end
end
def lang_paths(lang)
key_paths(nil, I18n.backend.send(:translations)[lang] || {}).flatten.sort
end
I18n.backend.load_translations # => Do it before running lang_paths(:en)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment