forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($i18n): makes the setLocaleData call append to the existing locales
- Loading branch information
1 parent
5c92e3d
commit feb0397
Showing
2 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { resetLocaleData, setLocaleData, __, getI18n } from '../index'; | ||
|
||
describe( 'wp.i18n', () => { | ||
describe( '.setLocaleData', () => { | ||
it('should set locale data', () => { | ||
resetLocaleData(); | ||
|
||
setLocaleData({ | ||
domain: 'gutenberg', | ||
locale_data: { | ||
gutenberg: { | ||
"": { | ||
domain: 'gutenberg', | ||
lang: 'ro_RO' | ||
}, | ||
Demo: ["Demonstrație"], | ||
['Gutenberg Team']: ["Echipa Gutenberg"] | ||
} | ||
} | ||
}); | ||
|
||
expect( __('Demo') ).toBe( 'Demonstrație' ); | ||
expect( __('Gutenberg Team') ).toBe( 'Echipa Gutenberg' ); | ||
}); | ||
|
||
it('should preserve local data between multiple .setLocaleData calls', () => { | ||
resetLocaleData(); | ||
|
||
setLocaleData({ | ||
domain: 'gutenberg', | ||
locale_data: { | ||
gutenberg: { | ||
"": { | ||
domain: 'gutenberg', | ||
lang: 'ro_RO' | ||
}, | ||
Demo: ["Demonstrație"] | ||
} | ||
} | ||
}); | ||
|
||
setLocaleData({ | ||
...getI18n().options, | ||
locale_data: { | ||
gutenberg: { | ||
...getI18n().options.locale_data.gutenberg, | ||
['Gutenberg Team']: ["Echipa Gutenberg"] | ||
} | ||
} | ||
}); | ||
|
||
expect( __('Gutenberg Team') ).toBe( 'Echipa Gutenberg' ); | ||
} ); | ||
} ); | ||
} ); |