Created
March 14, 2022 09:09
-
-
Save james/1349db428b4a25892ddddb82ddd380e8 to your computer and use it in GitHub Desktop.
This file contains 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
desc "Will replace i18n references in specs with actual text from default locale" | |
task undo_i18n_in_specs: :environment do | |
Dir[Rails.root.join("spec/features/**/*.rb")].collect do |file_name| | |
file_text = File.read(file_name) | |
file_text.scan(/\Wt\("([\w\.]+)"\)/).each do |match| | |
file_text.gsub!("t(\"#{match.first}\")", "\"#{I18n.t(match.first)}\"") | |
end | |
File.open(file_name, "w") { |file| file.puts file_text } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment