jamuhl/i18next — pull request #177 by jriecken (2013-11-25 04:56:42+00:00)
Title: Make returnObjectTrees not mangle arrays, functions, and regexps

The `returnObjectTrees` option mangles `Array`s, `function`s and `RegExp`s.

- Arrays are turned into array-like objects with numeric property names (but are not actually arrays)
- Functions are turned into empty objects (`{}`)
- RegExps are turned into empty objects (`{}`)

I've fixed it so that these types are correctly handled.

Before my fix:

{
res: 'added __replace__',
id: 0,
regex: /x/,
func: function () {},
template: '4',
title: 'About...',
text: 'Site description',
media: ['test']
}

Would get turned into (assuming "two" is passed in as the "replace" value):

{
res: 'added two',
id: 0,
regex: {},
func: {},
template: '4',
title: 'About...',
text: 'Site description',
media: { 0: 'test' }
}

After my fix it gets turned into:

{
res: 'added two',
id: 0,
regex: /x/,
func: function () {},
template: '4',
title: 'About...',
text: 'Site description',
media: ['test']
}