Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

Allow adding translations to an existing jed object #10

Merged
merged 1 commit into from Aug 5, 2016

Conversation

yoavf
Copy link
Contributor

@yoavf yoavf commented Jul 28, 2016

This introduces addTranslations() which takes a translations object and adds it do the existing one. Fixes #8

* Adds new translations to the locale data, overwriting any existing translations with a matching key
**/
I18N.prototype.addTranslations = function( localeData ) {
for ( var prop in localeData ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ES5 here? then we could do:

delete localeData[''];
Object.assign( this.state.jed.options.locale_data.messages, localeData );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or use lodash.merge and lodash.omit:
merge( this.state.jed.options.locale_data.messages, omit( localeData, '' ) )

@akirk akirk merged commit ed3f2fa into master Aug 5, 2016
@akirk akirk deleted the add/addTranslations branch August 5, 2016 11:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants