fnando/i18n-js — pull request #218 by johnnyshields (2014-06-10 08:06:30+00:00)
Title: Add "namespace" option to i18n-js.yml

In some cases I'd like to export the I18n keys to a different Javascript namespace than `I18n`, to avoid conflicts. For example, I have a widget-type component which is embedded in third-party websites, and many of these sites already define the `I18n` namespace.

To do this, I have added an optional `:namespace` key to `i18n-js.yml`.

In theory this should be a small change to implement, but the `js.rb` (exporter) code is written in a tightly-coupled fashion. I've refactored the code to extract a `Segment` class, which is extensible in case we'd like to add other similar options in the future.

All tests are passing, and I've added additional tests specific to the new `Segment` class.