Last active
September 3, 2020 18:41
-
-
Save zawyelwin/789c802acc5f1fb9ba8513a93145c42a to your computer and use it in GitHub Desktop.
A Simple YAML flatten script with dot notation.
This file contains hidden or 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
en: | |
questions: | |
new: 'New Question' | |
other: | |
recent: 'Recent' | |
old: 'Old' |
This file contains hidden or 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' | |
require 'json' | |
require 'i18n' | |
yaml = YAML::load(STDIN.read); | |
include I18n::Backend::Flatten | |
puts JSON.pretty_generate flatten_translations(nil, yaml, nil, false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
$ gem install i18n $ ruby yaml-flat.rb < test.yml
Output