airbnb/polyglot.js — pull request #8 by curtainrising (2013-08-22 23:31:12+00:00)
Title: Adding functionality around sets of localization bundles through polyglot

The reason for this change is simplicity on the front end. We are using "widgetized" templates in our code, essentially grouping the templates and localization by widget name. There were two obvious ways of solving this for polyglot:

A: Concatenating the widget name and string name, this is fine when looking for individual strings but requires weird for loops, or naming the key the concatination in the template. This would not provide a straightforward way to interact with templates.
B: Put an array of arrays, with each array of localized key=>value indexed by widget name, in to polyglot so that polyglot.t(...) would return an associative array. This worked better with templates but essentially skipped the point of using polyglot without some kind of helper function.

Because of the ease of naming, separation of the widgets, and our use of templates I had decided on B. However, there was still the issue of essentially not automatically using polyglot's functionality. In looking at the code it became clear a small change to polyglot would allow the use of a bundle of bundles, and polyglot functionality.

In adding these two functions I hope to increase the versatility of this simple to use and largely effective helper library.