Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@toshi3221
Created March 2, 2015 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshi3221/53816d60947e2bf91e7b to your computer and use it in GitHub Desktop.
Save toshi3221/53816d60947e2bf91e7b to your computer and use it in GitHub Desktop.
Rails翻訳依頼のためのHTML変換スクリプト
require 'yaml'
def to_html hash, html='', prefix_key=''
hash.each do |key, value|
html = if value.is_a? String
html+"<tr><td>#{prefix_key[0..-1]+key}</td><td>#{value}</td></tr>\n"
else
to_html value, html, prefix_key+key+'.'
end
end
return html
end
open('ja.html', 'w') do |f|
hash = YAML.load_file 'ja.yml'
f.write '<html><body><table>'
f.write to_html hash
f.write '</table></body></html>'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment