diff --git a/index.js b/index.js index 17da0aa..a5dc4bd 100644 --- a/index.js +++ b/index.js @@ -252,6 +252,8 @@ class I18nChild extends I18n { this.$scope = scopeChain.join('.') || undefined; this.parent = parent; + this[MISSING] = this.parent[MISSING]; + this[EMPTY] = this.parent[EMPTY]; } /** diff --git a/package.json b/package.json index b10595f..913d5e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fiverr/i18n", - "version": "1.8.0", + "version": "1.8.1", "description": "Translation helper", "keywords": [ "i18n", diff --git a/tests/child.js b/tests/child.js index e026708..6e935fe 100644 --- a/tests/child.js +++ b/tests/child.js @@ -57,4 +57,26 @@ describe('child instances', () => { expect(child.t('key')).to.equal('Child'); expect(child.t('key', {$scope: 'something'})).to.equal('Something'); }); + + it('Child calls parent onmiss functionallity', () => { + const i18n = new I18n({translations}); + let miss = 0; + i18n.onmiss(() => miss++); + const child = i18n.spawn('child'); + child.t('missing_translation'); + expect(miss).to.equal(1); + }); + + it('Child overrides parent onmiss functionallity', () => { + const i18n = new I18n({translations}); + let miss = 0; + let childMiss = 0; + i18n.onmiss(() => miss++); + const child = i18n.spawn('child'); + child.onmiss(() => childMiss++); + + child.t('missing_translation'); + expect(miss).to.equal(0); + expect(childMiss).to.equal(1); + }); });