List All Email Templates in Thai Language
Purpose
This script lists all Thai email template files (*_th.html.erb) in the Rails app and writes the result to email_templates_th.txt.
Reference
Prerequisites
- Ruby installed
- Rails project directory available
How to run
- Save script as
list_th_email_templates.rb. - Run:
ruby list_th_email_templates.rb
- Verify output file:
email_templates_th.txt.
Script
require 'find'
directory_to_search = 'app/views'
file_pattern = /.*_th\.html\.erb$/
output_file = 'email_templates_th.txt'
matching_files = []
Find.find(directory_to_search) do |path|
matching_files << path if path =~ file_pattern
end
File.open(output_file, 'w') do |file|
matching_files.each { |file_path| file.puts(file_path) }
end
puts "Matching files have been listed in #{output_file}"