Skip to content

Instantly share code, notes, and snippets.

@parndt
Created January 20, 2012 01:26
Show Gist options
  • Save parndt/1644377 to your computer and use it in GitHub Desktop.
Save parndt/1644377 to your computer and use it in GitHub Desktop.
Psych outputs a different file than it read in
require 'yaml'
my_yaml = YAML::load(File.read('en.yml')).to_yaml
=begin
1.9.3-p0 :002 > YAML::load(File.read('en.yml')).to_yaml
=> "---\nen:\n refinery:\n plugins:\n lovelies:\n title: Lovely Profiles\n people:\n admin:\n lovelies:\n actions:\n create_new: Add New Lovely profile\n reorder: Reorder Lovely profiles\n reorder_done: Done Reordering Lovely profiles\n records:\n title: Lovely\n sorry_no_results: Sorry! There are no results found.\n no_items_yet: There are no Lovely profiles yet. Click \"Add New Lovely\n profile\" to add one.\n lovely:\n view_live_html: View the lovely area live <br/><em>(opens in a new window)</em>\n edit: Edit this lovely profile\n delete: Remove this lovely profile forever\n lovelies:\n show:\n other: Other Lovely profiles\n activerecord:\n attributes:\n refinery/things/lovely:\n name: Name\n title: Title\n photo: Photo\n bio: Bio\n"
=end
# the problem is this: no_items_yet: There are no Lovely profiles yet. Click \"Add New Lovely\n profile\" to add one.
# Note how after \"Add New Lovely there is a \n as is demonstrated in en_after.yml
File.open('en_after.yml', 'w+') {|f| f.puts my_yaml }
en:
refinery:
plugins:
lovelies:
title: Lovely Profiles
people:
admin:
lovelies:
actions:
create_new: Add New Lovely profile
reorder: Reorder Lovely profiles
reorder_done: Done Reordering Lovely profiles
records:
title: Lovely
sorry_no_results: Sorry! There are no results found.
no_items_yet: There are no Lovely profiles yet. Click "Add New Lovely profile" to add one.
lovely:
view_live_html: View the lovely area live <br/><em>(opens in a new window)</em>
edit: Edit this lovely profile
delete: Remove this lovely profile forever
lovelies:
show:
other: Other Lovely profiles
activerecord:
attributes:
'refinery/things/lovely':
name: Name
title: Title
photo: Photo
bio: Bio
---
en:
refinery:
plugins:
lovelies:
title: Lovely Profiles
people:
admin:
lovelies:
actions:
create_new: Add New Lovely profile
reorder: Reorder Lovely profiles
reorder_done: Done Reordering Lovely profiles
records:
title: Lovely
sorry_no_results: Sorry! There are no results found.
no_items_yet: There are no Lovely profiles yet. Click "Add New Lovely
profile" to add one.
lovely:
view_live_html: View the lovely area live <br/><em>(opens in a new window)</em>
edit: Edit this lovely profile
delete: Remove this lovely profile forever
lovelies:
show:
other: Other Lovely profiles
activerecord:
attributes:
refinery/things/lovely:
name: Name
title: Title
photo: Photo
bio: Bio
@parndt
Copy link
Author

parndt commented Jan 24, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment