refactor(compiler): [i18n] move dedup and placeholder mapping to the MessageBundle
It makes implementing a `Serializer` simpler as implementations do not have to care any more about message dedup and placeholder mapping.
This commit is contained in:

committed by
Alex Rickabaugh

parent
d02eab498f
commit
c3e5ddbe20
@ -28,14 +28,13 @@ export function main(): void {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should extract the all messages and duplicates', () => {
|
||||
it('should extract and dedup messages', () => {
|
||||
messages.updateFromTemplate(
|
||||
'<p i18n="m|d">Translate Me</p><p i18n>Translate Me</p><p i18n>Translate Me</p>', 'url',
|
||||
DEFAULT_INTERPOLATION_CONFIG);
|
||||
'<p i18n="m|d@@1">Translate Me</p><p i18n="@@2">Translate Me</p><p i18n="@@2">Translate Me</p>',
|
||||
'url', DEFAULT_INTERPOLATION_CONFIG);
|
||||
expect(humanizeMessages(messages)).toEqual([
|
||||
'Translate Me (m|d)',
|
||||
'Translate Me (|)',
|
||||
'Translate Me (|)',
|
||||
]);
|
||||
});
|
||||
});
|
||||
@ -50,7 +49,7 @@ class _TestSerializer extends Serializer {
|
||||
|
||||
load(content: string, url: string): {} { return null; }
|
||||
|
||||
digest(msg: i18n.Message): string { return 'unused'; }
|
||||
digest(msg: i18n.Message): string { return msg.id || `default`; }
|
||||
}
|
||||
|
||||
function humanizeMessages(catalog: MessageBundle): string[] {
|
||||
|
Reference in New Issue
Block a user