Created
May 17, 2013 14:44
-
-
Save johnbintz/5599504 to your computer and use it in GitHub Desktop.
Autogenerate and autosort missing i18n translation keys for a Rails application while running Cucumber features
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
# Put this in features/support/hooks.rb and add i18n-missing_translations and i18n_yaml_sorter to your Gemfile | |
require 'i18n/missing_translations' | |
require 'i18n_yaml_sorter' | |
at_exit do | |
require 'yaml' | |
data = YAML.load_file('config/locales/en.yml') | |
data.deep_merge!(I18n.missing_translations) | |
output = StringIO.new(YAML.dump(data)) | |
File.open('config/locales/en.yml', 'wb') { |fh| fh.puts I18nYamlSorter::Sorter.new(output).sort } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment