Skip to content

Change the priority of scope lookup

Compare
Choose a tag to compare
@benbakhar benbakhar released this 04 Aug 08:42
· 20 commits to master since this release
5196d15

Scoped results are preferred to un-scoped when a scope is supplied

const i18n = new I18n({translations: {
    key: 'Top',
    child: { key: 'Child' },
    something: { key: 'Something' }
}});

const child = i18n.spawn('child');

i18n.t('key'); // Top
i18n.t('key', {$scope: 'something'}); // Something
child.t('key'); // Child
child.t('key', {$scope: 'something'}); // Something (explicit scope is strongest)