anatoliychakkaev/rwjs — pull request #1 by VladimirTechMan (2011-12-18 17:27:14+00:00)
Title: Small improvements and fixes in locales.load()

I propose making a few changes in locales.load(), as follows:

- Currently the yaml module (used in RailwayJS) cannot correctly handle YAML strings where lines are separated with CRLF (think Windows files). Given that the yaml implementation is a kind of generic one, potentially targeting client (in-browser) usages as well -- where CRLF line separation is more "exotic" -- I believe that it is reasonable to let YAML expect just LF line endings and prepare file contents for it a little bit. That's what the proposed fix does. It also handles the CR-only line endings (just in case; though it is unlikely we'll see files from old Macs). Handling Windows-encoded text files is required now, as node.js for Windows is official and is in use (well, I am using it as one of my development platforms for node.js, in particular :) ).

- Allow both .yml and .yaml extensions for locale YAML files; In practice both options are widely used;

- Make locales.load() more robust on files in config/locales that are not successfully handled (if parsing fails or if the file extension in config/locales is not supported/known -- a log message in the later case seems reasonable to me, though feel free to remove it if you want to silently ignore unknown files).

Hope that will be useful.