Last active
September 12, 2018 08:44
-
-
Save Bor1s/d89af83c61349e14c1605465a9a7f46e to your computer and use it in GitHub Desktop.
Script to show all nested I18n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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