feat(i18n): xtb serializer

This commit is contained in:
Victor Berchet
2016-07-21 13:56:58 -07:00
parent 1b77604ee2
commit 0eee1d5de3
71 changed files with 3152 additions and 4240 deletions

View File

@ -7,7 +7,6 @@
*/
import './init';
let serializer = require('@angular/compiler/src/i18n/xmb_serializer.js');
import * as fs from 'fs';
import * as path from 'path';
@ -16,13 +15,14 @@ describe('template i18n extraction output', () => {
const outDir = '';
it('should extract i18n messages', () => {
const EXPECTED = `<? xml version="1.0" encoding="UTF-8" ?>
<messagebundle>
<msg id="5a2858f1" desc="desc" meaning="meaning">translate me</msg>
</messagebundle>`;
const xmbOutput = path.join(outDir, 'messages.xmb');
expect(fs.existsSync(xmbOutput)).toBeTruthy();
const xmb = fs.readFileSync(xmbOutput, {encoding: 'utf-8'});
const res = serializer.deserializeXmb(xmb);
const keys = Object.keys(res.messages);
expect(keys.length).toEqual(1);
expect(res.errors.length).toEqual(0);
expect(res.messages[keys[0]][0].value).toEqual('translate me');
expect(xmb).toEqual(EXPECTED);
});
});