How can I sort YAML files?

前端 未结 9 935
灰色年华
灰色年华 2021-02-02 12:55

I\'ve been trying to sort an i18n translations YAML file with Ruby so I can manage new translations in a better and organized way, but I\'ve been wondering if there is something

9条回答
  •  既然无缘
    2021-02-02 13:03

    UPDATE April 2014:

    Using Rails 3.2.13, Ruby 1.9.3p489:

    I just used the i18n_yaml_sorter gem ( https://github.com/redealumni/i18n_yaml_sorter ).

    Simply add to your Gemfile:

    gem 'i18n_yaml_sorter', group: :development
    

    Then run the rake task to sort your locales' files:

    rake i18n:sort
    

    Worked perfectly, even though the gem has been last authored 2 years ago. It took 5 minutes max.

提交回复
热议问题