遍历rails框架下app中带.t的翻译

require 'pathname'
def deal_file(name, buffer)
  file=File.open(name,'r')
  content=file.read
  file.close
  results=content.scan /'([^']*?)'\.t/
  buffer+=results
  results=content.scan /\"([^"]*?)\"\.t/
  buffer
end
def deal_path(path,buffer)
  path.children.each do |pp|
    if pp.file?
      buffer = deal_filepp.to_s,buffer
    else
      buffer = deal_path pp,buffer
    end
  end
  buffer
end
buffer=[]
path=Pathname.new 'app'
buffer=deal_path path,buffer
file=File.open('trans.txt','wb')
lines=[]
buffer.each do |b|
  b.each do |bb|
    lines << bb
  end
end
lines.uniq.each do |u|
  file << u << "\r\n"
end
file.close

你可能感兴趣的:(Rails)