Created
March 2, 2015 09:03
-
-
Save toshi3221/53816d60947e2bf91e7b to your computer and use it in GitHub Desktop.
Rails翻訳依頼のためのHTML変換スクリプト
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
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